--HG--
branch : develop
This commit is contained in:
dismine 2014-01-27 18:01:24 +02:00
parent 11b5c00c89
commit cf2f076346
21 changed files with 52 additions and 50 deletions

View File

@ -218,20 +218,20 @@ void VContainer::UpdateId(qint64 newId)
QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &points) QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &points)
{ {
QVector<QPointF> correctPoints; QVector<QPointF> correctPoints;
if(points.size()<4)//Better don't check if only three points. We can destroy equidistant. if (points.size()<4)//Better don't check if only three points. We can destroy equidistant.
{ {
qWarning()<<"Only three points."; qWarning()<<"Only three points.";
return points; return points;
} }
//Clear equivalent points //Clear equivalent points
for(qint32 i = 0; i <points.size(); ++i) for (qint32 i = 0; i <points.size(); ++i)
{ {
if(i == points.size()-1) if (i == points.size()-1)
{ {
correctPoints.append(points.at(i)); correctPoints.append(points.at(i));
continue; continue;
} }
if(points.at(i) == points.at(i+1)) if (points.at(i) == points.at(i+1))
{ {
correctPoints.append(points.at(i)); correctPoints.append(points.at(i));
++i; ++i;
@ -241,13 +241,13 @@ QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &po
correctPoints.append(points.at(i)); correctPoints.append(points.at(i));
} }
} }
if(correctPoints.size()<3) if (correctPoints.size()<3)
{ {
return correctPoints; return correctPoints;
} }
//Remove point on line //Remove point on line
QPointF point; QPointF point;
for(qint32 i = 1; i <correctPoints.size()-1; ++i) for (qint32 i = 1; i <correctPoints.size()-1; ++i)
{ {
QLineF l1(correctPoints[i-1], correctPoints[i]); QLineF l1(correctPoints[i-1], correctPoints[i]);
QLineF l2(correctPoints[i], correctPoints[i+1]); QLineF l2(correctPoints[i], correctPoints[i+1]);

View File

@ -111,4 +111,3 @@ void DialogCutArc::setPointName(const QString &value)
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(pointName);
} }

View File

@ -31,8 +31,9 @@
#include "dialogtool.h" #include "dialogtool.h"
namespace Ui { namespace Ui
class DialogCutArc; {
class DialogCutArc;
} }
/** /**

View File

@ -129,14 +129,13 @@ QVector<QPointF> VArc::GetPoints() const
line.setAngle(line.angle()+i); line.setAngle(line.angle()+i);
points.append(line.p2()); points.append(line.p2());
i = i + s; i = i + s;
if(i > angle) if (i > angle)
{ {
QLineF line(center.toQPointF(), GetP1()); QLineF line(center.toQPointF(), GetP1());
line.setAngle(line.angle()+angle); line.setAngle(line.angle()+angle);
points.append(line.p2()); points.append(line.p2());
} }
} } while (i <= angle);
while(i <= angle);
return points; return points;
} }

View File

@ -113,7 +113,7 @@ void VDetail::setId(const qint64 &id)
bool VDetail::OnEdge(const qint64 &p1, const qint64 &p2) const bool VDetail::OnEdge(const qint64 &p1, const qint64 &p2) const
{ {
QVector<VNodeDetail> list = listNodePoint(); QVector<VNodeDetail> list = listNodePoint();
if(list.size() < 3) if (list.size() < 3)
{ {
qWarning()<<"Not enough points."; qWarning()<<"Not enough points.";
return false; return false;
@ -198,9 +198,9 @@ VDetail VDetail::RemoveEdge(const ptrdiff_t &index) const
QVector<VNodeDetail> list = this->listNodePoint(); QVector<VNodeDetail> list = this->listNodePoint();
qint32 edge = list.size(); qint32 edge = list.size();
ptrdiff_t k = 0; ptrdiff_t k = 0;
for(ptrdiff_t i=0; i<edge; ++i) for (ptrdiff_t i=0; i<edge; ++i)
{ {
if(i == index) if (i == index)
{ {
det.append(this->at(k)); det.append(this->at(k));
++k; ++k;
@ -212,17 +212,17 @@ VDetail VDetail::RemoveEdge(const ptrdiff_t &index) const
this->NodeOnEdge(i, p1, p2); this->NodeOnEdge(i, p1, p2);
ptrdiff_t j1 = this->indexOfNode(p1.getId()); ptrdiff_t j1 = this->indexOfNode(p1.getId());
ptrdiff_t j2 = this->indexOfNode(p2.getId()); ptrdiff_t j2 = this->indexOfNode(p2.getId());
if(j2 == 0) if (j2 == 0)
{ {
j2 = this->CountNode()-1; j2 = this->CountNode()-1;
if(j1 == j2) if (j1 == j2)
{ {
det.append(this->at(j1)); det.append(this->at(j1));
++k; ++k;
continue; continue;
} }
} }
for(ptrdiff_t j=j1; j<j2; ++j) for (ptrdiff_t j=j1; j<j2; ++j)
{ {
det.append(this->at(j)); det.append(this->at(j));
++k; ++k;
@ -235,15 +235,15 @@ VDetail VDetail::RemoveEdge(const ptrdiff_t &index) const
QList<qint64> VDetail::Missing(const VDetail &det) const QList<qint64> VDetail::Missing(const VDetail &det) const
{ {
QList<qint64> list; QList<qint64> list;
if(nodes.size() == det.CountNode()) if (nodes.size() == det.CountNode())
{ {
return list; return list;
} }
qint32 j = 0; qint32 j = 0;
for(qint32 i = 0; i < nodes.size(); ++i) for (qint32 i = 0; i < nodes.size(); ++i)
{ {
if(nodes[i].getId() == det.at(j).getId()) if (nodes[i].getId() == det.at(j).getId())
{ {
++j; ++j;
} }

View File

@ -212,4 +212,3 @@ void VSplinePath::setMaxCountPoints(const qint32 &value)
{ {
maxCountPoints = value; maxCountPoints = value;
} }

View File

@ -93,7 +93,8 @@ MainWindow::MainWindow(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
static const char * GENERIC_ICON_TO_CHECK = "document-open"; static const char * GENERIC_ICON_TO_CHECK = "document-open";
if (!QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK)) { if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
{
//If there is no default working icon theme then we should //If there is no default working icon theme then we should
//use an icon theme that we provide via a .qrc file //use an icon theme that we provide via a .qrc file
//This case happens under Windows and Mac OS X //This case happens under Windows and Mac OS X
@ -728,7 +729,7 @@ void MainWindow::currentDrawChanged( int index )
{ {
doc->setCurrentData(); doc->setCurrentData();
doc->ChangeActivDraw(comboBoxDraws->itemText(index)); doc->ChangeActivDraw(comboBoxDraws->itemText(index));
if(drawMode) if (drawMode)
{ {
ArrowTool(); ArrowTool();
qint64 id = doc->SPointActiveDraw(); qint64 id = doc->SPointActiveDraw();
@ -1241,7 +1242,7 @@ bool MainWindow::ValidatePattern(const QString &schema, const QString &fileName,
errorColumn = -1; errorColumn = -1;
return false; return false;
} }
if(schema.isEmpty()) if (schema.isEmpty())
{ {
errorMsg = QString(tr("Empty schema path.")); errorMsg = QString(tr("Empty schema path."));
errorLine = -1; errorLine = -1;
@ -1249,7 +1250,7 @@ bool MainWindow::ValidatePattern(const QString &schema, const QString &fileName,
return false; return false;
} }
QFile fileSchema(schema); QFile fileSchema(schema);
if(fileSchema.open(QIODevice::ReadOnly) == false) if (fileSchema.open(QIODevice::ReadOnly) == false)
{ {
errorMsg = QString(tr("Can't open schema file.")); errorMsg = QString(tr("Can't open schema file."));
errorLine = -1; errorLine = -1;
@ -1263,14 +1264,14 @@ bool MainWindow::ValidatePattern(const QString &schema, const QString &fileName,
sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName())); sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName()));
bool errorOccurred = false; bool errorOccurred = false;
if (!sch.isValid()) if (sch.isValid() == false)
{ {
errorOccurred = true; errorOccurred = true;
} }
else else
{ {
QXmlSchemaValidator validator(sch); QXmlSchemaValidator validator(sch);
if (!validator.validate(&pattern, QUrl::fromLocalFile(pattern.fileName()))) if (validator.validate(&pattern, QUrl::fromLocalFile(pattern.fileName())) == false)
{ {
errorOccurred = true; errorOccurred = true;
} }
@ -1400,7 +1401,7 @@ void MainWindow::OpenPattern(const QString &fileName)
qint64 errorColumn = 0; qint64 errorColumn = 0;
if (file.open(QIODevice::ReadOnly)) if (file.open(QIODevice::ReadOnly))
{ {
if(ValidatePattern("://schema/pattern.xsd", fileName, errorMsg, errorLine, errorColumn)) if (ValidatePattern("://schema/pattern.xsd", fileName, errorMsg, errorLine, errorColumn))
{ {
qint32 errorLine = 0; qint32 errorLine = 0;
qint32 errorColumn = 0; qint32 errorColumn = 0;

View File

@ -174,8 +174,10 @@ void TableWindow::saveScene()
i.next(); i.next();
saveMessage += i.key(); saveMessage += i.key();
if (i.hasNext()) if (i.hasNext())
{
saveMessage += ";;"; saveMessage += ";;";
} }
}
QString sf; QString sf;
// the save function // the save function
@ -446,8 +448,9 @@ void TableWindow::PdfFile(const QString &name) const
printer.setResolution(PrintDPI); printer.setResolution(PrintDPI);
printer.setPaperSize ( QSizeF(toMM(w), toMM(h)), QPrinter::Millimeter ); printer.setPaperSize ( QSizeF(toMM(w), toMM(h)), QPrinter::Millimeter );
QPainter painter; QPainter painter;
if (! painter.begin( &printer )) { // failed to open file if (painter.begin( &printer ) == false)
qCritical("Can't open printer %s",qPrintable(name)); { // failed to open file
qCritical("Can't open printer %s", qPrintable(name));
return; return;
} }
painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setFont( QFont( "Arial", 8, QFont::Normal ) );

View File

@ -159,7 +159,7 @@ void VToolPoint::RefreshLine()
LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - scenePos())); lineName->setLine(QLineF(p1, pRec - scenePos()));
if(currentColor == Qt::gray) if (currentColor == Qt::gray)
{ {
lineName->setPen(QPen(currentColor, widthHairLine/factor)); lineName->setPen(QPen(currentColor, widthHairLine/factor));
} }

View File

@ -95,8 +95,8 @@ signals:
* @param controlPoint new position control point. * @param controlPoint new position control point.
* @param splinePoint new position spline point. * @param splinePoint new position spline point.
*/ */
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position, const QPointF &controlPoint, void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &splinePoint ); const QPointF &controlPoint, const QPointF &splinePoint );
/** /**
* @brief setEnabledPoint disable control points. * @brief setEnabledPoint disable control points.
* @param enable enable or diasable points. * @param enable enable or diasable points.

View File

@ -59,7 +59,7 @@ void VNodeArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idA
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, idTool, parent); VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, idTool, parent);
Q_ASSERT(arc != 0); Q_ASSERT(arc != 0);
doc->AddTool(id, arc); doc->AddTool(id, arc);
if(idTool != 0) if (idTool != 0)
{ {
doc->IncrementReferens(idTool); doc->IncrementReferens(idTool);
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.

View File

@ -70,7 +70,7 @@ void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 i
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, parent); VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, parent);
Q_ASSERT(point != 0); Q_ASSERT(point != 0);
doc->AddTool(id, point); doc->AddTool(id, point);
if(idTool != 0) if (idTool != 0)
{ {
doc->IncrementReferens(idTool); doc->IncrementReferens(idTool);
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.

View File

@ -61,7 +61,7 @@ VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id,
{ {
spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, idTool, parent); spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, idTool, parent);
doc->AddTool(id, spl); doc->AddTool(id, spl);
if(idTool != 0) if (idTool != 0)
{ {
doc->IncrementReferens(idTool); doc->IncrementReferens(idTool);
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.

View File

@ -65,7 +65,7 @@ void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qin
const QVector<VSplinePoint> *points = path->GetPoint(); const QVector<VSplinePoint> *points = path->GetPoint();
for (qint32 i = 0; i<points->size(); ++i) for (qint32 i = 0; i<points->size(); ++i)
{ {
if(idTool != 0) if (idTool != 0)
{ {
doc->IncrementReferens(idTool); doc->IncrementReferens(idTool);
//Some nodes we don't show on scene. Tool that create this nodes must free memory. //Some nodes we don't show on scene. Tool that create this nodes must free memory.

View File

@ -84,7 +84,7 @@ void VAbstractTool::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view)
QTransform t = view->transform(); QTransform t = view->transform();
QRectF rec1; QRectF rec1;
if(t.m11() < 1) if (t.m11() < 1)
{ {
rec1 = QRect(0, 0, rec0.width()/t.m11(), rec0.height()/t.m22()); rec1 = QRect(0, 0, rec0.width()/t.m11(), rec0.height()/t.m22());
@ -227,7 +227,7 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool)
RemoveReferens();//deincrement referens RemoveReferens();//deincrement referens
element.removeChild(domElement);//remove form file element.removeChild(domElement);//remove form file
QGraphicsScene *scene = tool->scene(); QGraphicsScene *scene = tool->scene();
if(scene != 0)//some tools haven't scene if (scene != 0)//some tools haven't scene
{ {
scene->removeItem(tool);//remove form scene scene->removeItem(tool);//remove form scene
} }

View File

@ -188,9 +188,9 @@ void VToolDetail::FullUpdateFromGui(int result)
VDetail detail = VAbstractTool::data.GetDetail(id); VDetail detail = VAbstractTool::data.GetDetail(id);
QList<qint64> list = detail.Missing(det); QList<qint64> list = detail.Missing(det);
QHash<qint64, VDataTool*>* tools = doc->getTools(); QHash<qint64, VDataTool*>* tools = doc->getTools();
if(list.size()>0) if (list.size()>0)
{ {
for(qint32 i = 0; i < list.size(); ++i) for (qint32 i = 0; i < list.size(); ++i)
{ {
VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(list[i])); VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(list[i]));
node->DeleteNode(); node->DeleteNode();

View File

@ -213,7 +213,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VDomDocument *doc, VContai
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle2()+180, path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle2()+180,
splinePath->at(i).KAsm2())); splinePath->at(i).KAsm2()));
} }
while(k>=0) while (k>=0)
{ {
data->getNextId(); data->getNextId();
--k; --k;
@ -371,7 +371,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
splinePath->at(i).KAsm2())); splinePath->at(i).KAsm2()));
} }
while(k>=0) while (k>=0)
{ {
data->getNextId(); data->getNextId();
--k; --k;
@ -522,7 +522,7 @@ void VToolUnionDetails::Create(const qint64 _id, const VDetail &d1, const VDetai
++j; ++j;
} while (pointsD2 < nD2); } while (pointsD2 < nD2);
} }
}while(i<nD1); } while(i<nD1);
newDetail.setName("Detail"); newDetail.setName("Detail");
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Tool::FromTool); VToolDetail::Create(0, newDetail, scene, doc, data, parse, Tool::FromTool);
@ -607,7 +607,7 @@ void VToolUnionDetails::Create(const qint64 _id, const VDetail &d1, const VDetai
++j; ++j;
} while (pointsD2 < nD2); } while (pointsD2 < nD2);
} }
}while(i<nD1); } while(i<nD1);
} }
} }

View File

@ -78,7 +78,7 @@ void DoubleSpinBoxDelegate::commitAndCloseEditor()
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender()); QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
Q_ASSERT(spinBox != 0); Q_ASSERT(spinBox != 0);
qreal value = spinBox->value(); qreal value = spinBox->value();
if(qFuzzyCompare ( lastValue, value ) == false) if (qFuzzyCompare ( lastValue, value ) == false)
{ {
lastValue = value; lastValue = value;
emit commitData(spinBox); emit commitData(spinBox);

View File

@ -1428,7 +1428,7 @@ void VDomDocument::DecrementReferens(qint64 id) const
{ {
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
VDataTool *tool = tools.value(id); VDataTool *tool = tools.value(id);
if(tool != 0) if (tool != 0)
{ {
tool->decrementReferens(); tool->decrementReferens();
} }