35 #include "../ifc/ifcdef.h"
36 #include "../qmuparser/qmuparsererror.h"
37 #include "../tools/drawTools/vdrawtool.h"
38 #include "../vmisc/vcommonsettings.h"
39 #include "../vpatterndb/calculator.h"
40 #include "../vpatterndb/vcontainer.h"
41 #include "../vpatterndb/vtranslatevars.h"
42 #include "../vwidgets/scalesceneitems.h"
43 #include "../vwidgets/vcurvepathitem.h"
44 #include "../vwidgets/vmaingraphicsscene.h"
49 #include <QGraphicsEllipseItem>
50 #include <QGraphicsItem>
51 #include <QGraphicsLineItem>
53 #include <QMessageLogger>
57 #include <QScopedPointer>
62 template <
class K,
class V>
class QHash;
64 Q_LOGGING_CATEGORY(vVis,
"v.visualization")
72 , supportColor(QColor(
qApp->Settings()->getPrimarySupportColor()))
73 , lineStyle(Qt::SolidLine)
145 if (
toolTip.isEmpty() ==
false)
169 if (expression.isEmpty())
178 QString formula = expression;
179 formula.replace(
"\n",
" ");
180 formula =
qApp->TrVars()->FormulaFromUser(formula,
qApp->Settings()->GetOsSeparator());
181 QScopedPointer<Calculator> cal(
new Calculator());
182 val = cal->EvalFormula(vars, formula);
184 if (qIsInf(val) || qIsNaN(val))
192 qDebug() <<
"\nMath parser error:\n"
193 <<
"--------------------------------------\n"
194 <<
"Message: " << e.
GetMsg() <<
"\n"
195 <<
"Expression: " << e.
GetExpr() <<
"\n"
196 <<
"--------------------------------------";
209 QPen visPen = point->pen();
210 visPen.setColor(color);
211 visPen.setStyle(style);
213 point->setPen(visPen);
214 point->setVisible(
true);
219 const qreal &lineWeight, Qt::PenStyle style)
223 QPen visPen = lineItem->pen();
224 visPen.setColor(color);
225 visPen.setStyle(style);
228 lineItem->setPen(visPen);
229 lineItem->setLine(line);
230 lineItem->setVisible(
true);
235 Qt::PenStyle style,
const qreal &lineWeight, Qt::PenCapStyle cap)
243 const qreal &lineWeight, Qt::PenCapStyle cap)
247 QPen visPen = pathItem->pen();
248 visPen.setColor(color);
249 visPen.setStyle(style);
251 visPen.setCapStyle(cap);
253 pathItem->setPen(visPen);
254 pathItem->setPath(path);
256 pathItem->setVisible(
true);
266 QPen visPen = item->pen();
267 visPen.setColor(color);
268 visPen.setStyle(style);
270 item->setPen(visPen);
272 item->setVisible(
true);
307 arrowPart1.setP1(axis.p2());
308 arrowPart1.setLength(arrow_size);
309 arrowPart1.setAngle(axis.angle()+180+35);
311 path.moveTo(arrowPart1.p1());
312 path.lineTo(arrowPart1.p2());
315 arrowPart2.setP1(axis.p2());
316 arrowPart2.setLength(arrow_size);
317 arrowPart2.setAngle(axis.angle()+180-35);
319 path.moveTo(arrowPart2.p1());
320 path.lineTo(arrowPart2.p2());
325 const QColor &color, QGraphicsItem *parent)
327 if (not points.isEmpty() &&
static_cast<quint32
>(points.size() - 1) >= i)
329 return points.at(
static_cast<int>(i));
334 points.append(point);
345 point->setBrush(QBrush(Qt::NoBrush));
347 QPen visPen = point->pen();
348 visPen.setColor(color);
350 point->setPen(visPen);
352 point->setPos(QPointF());
353 point->setFlags(QGraphicsItem::ItemStacksBehindParent);
355 point->setVisible(
false);
The Calculator class for calculation formula.
The VContainer class container of all variables.
void SetDirectionArrows(const QVector< QPair< QLineF, QLineF >> &arrows)
The VMainGraphicsScene class main scene.
QPointF getScenePos() const
void mousePos(const QPointF &scenePos)
void ToolTip(const QString &toolTip)
void setScenePos(const QPointF &value)
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style=Qt::SolidLine)
void setLineWeight(const QString &value)
static qreal FindLength(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
void drawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size)
void SetMode(const Mode &value)
virtual void VisualMode(const quint32 &pointId)
static VScaledEllipse * initPointItem(const QColor &color, QGraphicsItem *parent, qreal z=0)
void setData(const VContainer *data)
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color, Qt::PenStyle style=Qt::SolidLine, const qreal &weight=0.35, Qt::PenCapStyle cap=Qt::SquareCap)
void setObject1Id(const quint32 &value)
static VScaledEllipse * GetPointItem(QVector< VScaledEllipse * > &points, quint32 i, const QColor &color, QGraphicsItem *parent)
const VContainer * getData() const
void drawArrowedLine(ArrowedLineItem *item, const QLineF &line, const QColor &color, Qt::PenStyle style=Qt::SolidLine)
virtual void RefreshGeometry()=0
virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, const qreal &lineWeight, Qt::PenStyle style=Qt::SolidLine)
VScaledEllipse * InitPoint(const QColor &color, QGraphicsItem *parent, qreal z=0) const
virtual void AddOnScene()=0
void setLineStyle(const Qt::PenStyle &value)
void setMainColor(const QColor &value)
static qreal FindVal(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
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.
double ToPixel(double val, const Unit &unit)
const qreal defPointRadiusPixel
QRectF PointRect(qreal radius)