56 #include <QDialogButtonBox>
58 #include <QGraphicsEllipseItem>
59 #include <QGraphicsLineItem>
63 #include <QMessageBox>
70 #include <QSharedPointer>
71 #include <QStaticStringData>
72 #include <QStringData>
73 #include <QStringDataPtr>
80 #include "../vgeometry/vpointf.h"
81 #include "../vpropertyexplorer/checkablemessagebox.h"
82 #include "../vwidgets/vmaingraphicsview.h"
83 #include "../ifc/exception/vexception.h"
84 #include "../ifc/exception/vexceptionundo.h"
85 #include "../ifc/xml/vtoolrecord.h"
86 #include "../undocommands/deltool.h"
87 #include "../vgeometry/../ifc/ifcdef.h"
88 #include "../vgeometry/vgeometrydef.h"
89 #include "../vgeometry/vgobject.h"
90 #include "../vgeometry/vcubicbezier.h"
91 #include "../vgeometry/vcubicbezierpath.h"
92 #include "../vgeometry/vsplinepath.h"
93 #include "../vgeometry/varc.h"
94 #include "../vgeometry/vellipticalarc.h"
95 #include "../vmisc/vcommonsettings.h"
96 #include "../vmisc/logging.h"
97 #include "../vpatterndb/vcontainer.h"
98 #include "../vpatterndb/vpiecenode.h"
99 #include "../vpatterndb/calculator.h"
100 #include "../vwidgets/vgraphicssimpletextitem.h"
102 #include "../dialogs/support/dialogundo.h"
103 #include "../dialogs/support/edit_formula_dialog.h"
117 return VAbstractTool::CreateNode<VSpline>(data,
id);
121 return VAbstractTool::CreateNode<VCubicBezier>(data,
id);
130 return VAbstractTool::CreateNode<VSplinePath>(data,
id);
134 return VAbstractTool::CreateNode<VCubicBezierPath>(data,
id);
163 if (not
vis.isNull())
188 QScopedPointer<Calculator> cal(
new Calculator());
191 if (qIsInf(result) || qIsNaN(result))
193 qDebug() <<
"Invalid the formula value";
199 qDebug() <<
"\nMath parser error:\n"
200 <<
"--------------------------------------\n"
201 <<
"Message: " << e.
GetMsg() <<
"\n"
202 <<
"Expression: " << e.
GetExpr() <<
"\n"
203 <<
"--------------------------------------";
205 if (
qApp->IsAppInGUIMode())
207 QScopedPointer<DialogUndo> dialogUndo(
new DialogUndo(
qApp->getMainWindow()));
210 if (dialogUndo->exec() == QDialog::Accepted)
212 const UndoButton resultUndo = dialogUndo->Result();
216 dialog->setWindowTitle(tr(
"Edit wrong formula"));
217 dialog->SetFormula(formula);
218 if (dialog->exec() == QDialog::Accepted)
220 formula = dialog->GetFormula();
224 QScopedPointer<Calculator> cal1(
new Calculator());
227 if (qIsInf(result) || qIsNaN(result))
229 qDebug() <<
"Invalid the formula value";
242 throw VExceptionUndo(QString(
"Undo wrong formula %1").arg(formula));
265 qCDebug(vTool,
"Deleting abstract tool.");
268 qCDebug(vTool,
"No children.");
269 qApp->getSceneView()->itemClicked(
nullptr);
272 qCDebug(vTool,
"Asking.");
275 qCDebug(vTool,
"User said no.");
280 qCDebug(vTool,
"Begin deleting.");
283 qApp->getUndoStack()->push(delTool);
291 qCDebug(vTool,
"Can't delete, tool has children.");
298 if (
false ==
qApp->Settings()->getConfirmItemDelete())
300 return QMessageBox::Yes;
304 msgBox.setWindowTitle(tr(
"Confirm deletion"));
305 msgBox.
setText(tr(
"Do you really want to delete?"));
308 msgBox.
setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32) );
310 int dialogResult = msgBox.exec();
312 if (dialogResult == QDialog::Accepted)
314 qApp->Settings()->setConfirmItemDelete(not msgBox.
isChecked());
317 return dialogResult == QDialog::Accepted ? QMessageBox::Yes : QMessageBox::No;
337 const QStringList colorNames =
Colors();
338 for (
int i = 0; i < colorNames.size(); ++i)
350 name = tr(
"Dark Red");
353 name = tr(
"Dark Green");
356 name = tr(
"Dark Blue");
362 name = tr(
"Light Salmon");
365 name = tr(
"Goldenrod");
371 name = tr(
"Deep Pink");
377 name = tr(
"Dark Violet");
380 name = tr(
"Medium Sea Green");
386 name = tr(
"Deep Sky Blue");
389 name = tr(
"Corn Flower Blue");
397 map.insert(colorNames.at(i), name);
406 map.insert(
"gold", tr(
"Gold"));
407 map.insert(
"forestgreen", tr(
"Forest Green"));
408 map.insert(
"lawngreen", tr(
"Lawn Green"));
409 map.insert(
"limegreen", tr(
"Lime Green"));
410 map.insert(
"greenyellow", tr(
"Green Yellow"));
411 map.insert(
"sandybrown", tr(
"Sandy Brown"));
412 map.insert(
"orangered", tr(
"Orange Red"));
413 map.insert(
"maroon", tr(
"Maroon"));
414 map.insert(
"pink", tr(
"Pink"));
415 map.insert(
"hotpink", tr(
"Hot Pink"));
416 map.insert(
"blueviolet", tr(
"Blue Violet"));
417 map.insert(
"mediumvioletred", tr(
"Medium Violet Red"));
418 map.insert(
"indigo", tr(
"Indigo"));
419 map.insert(
"purple", tr(
"Purple"));
420 map.insert(
"plum", tr(
"Plum"));
421 map.insert(
"turquoise", tr(
"Turquoise"));
422 map.insert(
"mediumturquoise", tr(
"Medium Turquoise"));
423 map.insert(
"powderblue", tr(
"Powder Blue"));
424 map.insert(
"lightskyblue", tr(
"Light Sky Blue"));
425 map.insert(
"navy", tr(
"Navy"));
426 map.insert(
"magenta", tr(
"Magenta"));
435 map.insert(
"darkslategrey", tr(
"Dark Slate Grey"));
436 map.insert(
"grey", tr(
"Grey"));
437 map.insert(
"gainsboro", tr(
"Gainsboro"));
438 map.insert(
"darkseagreen", tr(
"Dark Sea Green"));
439 map.insert(
"lightgrey", tr(
"Light Grey"));
440 map.insert(
"darkslategrey", tr(
"Dark Slate Grey"));
441 map.insert(
"lightsteelblue", tr(
"Light Steel Blue"));
442 map.insert(
"biege", tr(
"Biege"));
443 map.insert(
"thistle", tr(
"Thistle"));
444 map.insert(
"silver", tr(
"Silver"));
445 map.insert(
"whitesmoke", tr(
"White Smoke"));
446 map.insert(
"white", tr(
"White"));
447 map.insert(
"darkgrey", tr(
"Dark Grey"));
448 map.insert(
"cadetblue", tr(
"Cadet Blue"));
449 map.insert(
"darkkhaki", tr(
"Dark Khaki"));
450 map.insert(
"tan", tr(
"Tan"));
457 QPixmap pixmap(w, h);
458 pixmap.fill(QColor(Qt::black));
460 QPainter painter(&pixmap);
461 painter.setPen(Qt::black);
463 const QRect rectangle = QRect(1, 1, w-2, h-2);
465 qDebug()<<
"createColorIcon - color = "<< color;
467 if (color ==
"No Group")
469 painter.fillRect(rectangle, QColor(Qt::white));
470 painter.drawLine(0, 0, w, h);
471 painter.drawLine(0, h, w, 0);
473 else if (color ==
"By Group")
475 QFont font = painter.font();
476 font.setPixelSize(10);
477 painter.setFont(font);
478 painter.fillRect(rectangle, QColor(Qt::white));
479 painter.drawText(rectangle, Qt::AlignCenter,
"GROUP");
483 painter.fillRect(rectangle, QColor(color));
507 for (i = objs->constBegin(); i != objs->constEnd(); ++i)
515 list[point->name()] = i.key();
572 if (history->contains(record))
580 history->append(record);
585 for (qint32 i = 0; i<history->size(); ++i)
588 if (rec.
getId() == cursor)
594 history->insert(index+1, record);
608 domElement.appendChild(nodesElement);
621 QDomElement nod =
doc->createElement(tagName);
673 qDebug()<<
"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
678 const unsigned char angleType =
static_cast<unsigned char>(node.
GetAngleType());
755 id = CreateNode<VPointF>(
data, node.
GetId());
759 id = CreateNode<VArc>(
data, node.
GetId());
763 id = CreateNode<VEllipticalArc>(
data, node.
GetId());
775 qDebug()<<
"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
The Calculator class for calculation formula.
The CheckableMessageBox class implements a message box suitable for questions with a "Do not ask me a...
void setStandardButtons(QDialogButtonBox::StandardButtons s)
void setText(const QString &)
void setIconPixmap(const QPixmap &p)
void setDefaultButton(QDialogButtonBox::StandardButton s)
static const QString TagNode
virtual void LiteParseTree(const Document &parse)=0
void FullUpdateFromFile()
FullUpdateFromFile update tool data form file.
static const QString NodeArc
static const QString AttrNodeNotchType
static const QString NodePoint
void haveLiteChange()
haveLiteChange we have unsaved change.
static const QString AttrNodeNotchSubType
static const QString NodeSplinePath
static const QString NodeSpline
static const QString AttrNodeShowSecondNotch
static const QString AttrSAAfter
static const QString AttrNodeNotchLength
static const QString AttrNodeNotchCount
static const QString AttrSABefore
static const QString NodeElArc
static const QString AttrNodeReverse
QString getActiveDraftBlockName() const
getActiveDraftBlockName return current draft block name.
quint32 getCursor() const
static const QString AttrNodeExcluded
static const QString AttrNodeNotchAngle
static const QString AttrNodeIsNotch
static const QString AttrNodeNotchWidth
QVector< VToolRecord > * getHistory()
getHistory return list with list of history records.
static const QString TagNodes
static const QString AttrNodeShowNotch
The VContainer class container of all variables.
const QHash< QString, QSharedPointer< VInternalVariable > > * DataVariables() const
const QSharedPointer< VGObject > GetGObject(quint32 id) const
GetGObject returns a point by id.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
const QHash< quint32, QSharedPointer< VGObject > > * DataGObjects() const
data container with datagObjects return container of gObjects
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
The VMainGraphicsScene class main scene.
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=NULL_ID)
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, quint32 idPoint, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
static VNodeSpline * Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
PieceNodeAngle GetAngleType() const
NotchType getNotchType() const
QString GetFormulaSAAfter() const
qreal getNotchAngle() const
QString GetFormulaSABefore() const
qreal getNotchLength() const
int getNotchCount() const
NotchSubType getNotchSubType() const
qreal getNotchWidth() const
bool showSeamlineNotch() const
qint32 CountNodes() const
const VPieceNode & at(int indx) const
VPiecePath GetPath() const
The VPointF class keep data of point.
Error class of the parser.
const QString & GetMsg() const
Returns the message string for this error.
const QString & GetExpr() const
gets the expression related tp this error.
QString notchSubTypeToString(NotchSubType type)
QString notchTypeToString(NotchType type)
const QString ColorDarkRed
const QString ColorCornFlowerBlue
const QString FilldDiagonalCross
const QString FillBackwardDiagonal
const QString ColorMediumSeaGreen
const QString ColorYellow
const QString FillHorizLines
const QString ColorGoldenRod
const QString ColorDarkBlue
const QString ColorViolet
const QString currentSeamAllowance
const QString ColorLightSalmon
const QString ColorDarkGreen
const QString ColorDeepPink
const QString AttrIdObject
const QString FillVertLines
const QString ColorOrange
const QString ColorDeepSkyBlue
const QString ColorDarkViolet
const QString FillForwardDiagonal