23 #include <QApplication> 24 #include <QGraphicsItem> 30 QGraphicsScene(mainWindow),
31 m_pathItemMultiValued (nullptr)
43 <<
" identifer=" << identifier.toLatin1().data();
53 const QString &pointIdentifier0,
54 const QString &pointIdentifier1)
58 const double ORDINAL_0 = 0, ORDINAL_1 = 1;
72 const QPointF &posScreen,
76 <<
" identifier=" << identifier.toLatin1().data();
94 QString GraphicsScene::dumpCursors ()
const 96 QString cursorOverride = (QApplication::overrideCursor () !=
nullptr) ?
101 QString dump = QString (
"overrideCursor=%1 imageCursor=%2")
102 .arg (cursorOverride)
112 for (
int index = 0; index < QGraphicsScene::items().count(); index++) {
113 QGraphicsItem *item = QGraphicsScene::items().at(index);
127 const QGraphicsPixmapItem *GraphicsScene::image ()
const 130 QList<QGraphicsItem*> items = QGraphicsScene::items();
131 QList<QGraphicsItem*>::iterator itr;
132 for (itr = items.begin(); itr != items.end(); itr++) {
134 QGraphicsItem* item = *itr;
137 return dynamic_cast<QGraphicsPixmapItem *
> (item);
148 QStringList movedIds;
150 const QList<QGraphicsItem*> &items = QGraphicsScene::items();
151 QList<QGraphicsItem*>::const_iterator itr;
152 for (itr = items.begin(); itr != items.end(); itr++) {
154 const QGraphicsItem *item = *itr;
164 <<
" identifier=" << identifier.toLatin1().data()
165 <<
" positionHasChanged=" << (positionHasChanged ?
"yes" :
"no");
167 if (isPoint && positionHasChanged) {
188 LOG4CPP_INFO_S ((*
mainCat)) <<
"GraphicsScene::removePoint identifier=" << identifier.toLatin1().data();
209 int itemsBefore = items().count();
213 int itemsAfter = items().count();
216 <<
" itemsBefore=" << itemsBefore
217 <<
" itemsAfter=" << itemsAfter;
224 QList<QGraphicsItem*> itms = items ();
225 QList<QGraphicsItem*>::const_iterator itr;
226 for (itr = itms.begin (); itr != itms.end (); itr++) {
228 QGraphicsItem *item = *itr;
235 const QString &curveNameWanted)
238 <<
" show=" << (show ?
"true" :
"false")
239 <<
" showAll=" << (showAll ?
"true" :
"false")
240 <<
" curve=" << curveNameWanted.toLatin1().data();
242 const QList<QGraphicsItem*> &items = QGraphicsScene::items();
243 QList<QGraphicsItem*>::const_iterator itr;
244 for (itr = items.begin(); itr != items.end(); itr++) {
246 QGraphicsItem* item = *itr;
252 if (isPoint || isCurve) {
254 bool showThis = show;
255 if (show && !showAll) {
261 showThis = (curveNameWanted == curveNameGot);
265 showThis = (curveNameWanted == identifier);
270 item->setVisible (showThis);
277 double highlightOpacity,
285 updateCurves (cmdMediator);
288 updatePointMembership (cmdMediator,
293 void GraphicsScene::updateCurves (
CmdMediator &cmdMediator)
298 QStringList curveNames;
326 QPainterPath pathMultiValued;
333 updatePathItemMultiValued (pathMultiValued,
338 void GraphicsScene::updatePathItemMultiValued (
const QPainterPath &pathMultiValued,
342 int lineWidth = signed (lineMultiValued.
width());
345 delete m_pathItemMultiValued;
346 m_pathItemMultiValued = this->addPath (pathMultiValued);
347 m_pathItemMultiValued->setPen (QPen (QBrush (QColor (Qt::red)),
350 m_pathItemMultiValued->setAcceptHoverEvents (
true);
351 m_pathItemMultiValued->setToolTip (tr (
"Function currently has multiple Y values for one X value. Please adjust nearby points, " 352 "or change the curve type in Curve Properties"));
355 void GraphicsScene::updatePointMembership (
CmdMediator &cmdMediator,
365 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
381 QPainterPath pathMultiValued;
387 updatePathItemMultiValued (pathMultiValued,
void updateGraphicsLinesToMatchGraphicsPoints(const CurveStyles &curveStyles, SplineDrawer &splineDrawer, QPainterPath &pathMultiValued, LineStyle &lineMultiValued)
Calls to moveLinesWithDraggedPoint have finished so update the lines correspondingly.
void updateGraphicsLinesToMatchGraphicsPoints(const CurveStyles &modelCurveStyles, const Transformation &transformation)
A mouse move has just occurred so move the selected points, since they were dragged.
void removePoint(const QString &identifier)
Remove the specified point. The act of deleting it will automatically remove it from the GraphicsScen...
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
Factor for generating GraphicsPointAbstractBase class objects.
Callback for updating the QGraphicsItems in the scene after a command may have modified Points in Cur...
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void printStream(QString indentation, QTextStream &str)
Debugging method that supports print method of this class and printStream method of some other class(...
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
unsigned int width() const
Width of line.
GraphicsScene(MainWindow *mainWindow)
Single constructor.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
void addPoint(const QString &curveName, const QString &pointIdentifier, double ordinal, GraphicsPoint &point)
Add new point.
void lineMembershipReset()
Mark points as unwanted. Afterwards, lineMembershipPurge gets called.
void addTemporaryScaleBar(GraphicsPoint *point0, GraphicsPoint *point1, const QString &pointIdentifier0, const QString &pointIdentifier1)
Add temporary scale bar to scene.
void removeTemporaryScaleBarIfExists()
Remove temporary scale bar, composed of two points and the line between them.
#define LOG4CPP_INFO_S(logger)
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
Window that displays the geometry information, as a table, for the current curve. ...
QStringList positionHasChangedPointIdentifiers() const
Return a list of identifiers for the points that have moved since the last call to resetPositionHasCh...
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
CallbackSearchReturn callback(const QString &, const Point &point)
Callback method.
Unique identifier for QGraphicsItem object
void updateAfterCommand(CmdMediator &cmdMediator, double highlightOpacity, GeometryWindow *geometryWindow, const Transformation &transformation)
Update the Points and their Curves after executing a command.
GraphicsPoint * createPoint(QGraphicsScene &scene, const QString &identifier, const QPointF &posScreen, const PointStyle &pointStyle, GeometryWindow *geometryWindow)
Create circle or polygon point according to the PointStyle.
void updatePointOrdinalsAfterDrag(const CurveStyles &curveStyles, const Transformation &transformation)
See GraphicsScene::updateOrdinalsAfterDrag.
GraphicsPoint * createPoint(const QString &identifier, const PointStyle &pointStyle, const QPointF &posScreen, GeometryWindow *geometryWindow)
Create one QGraphicsItem-based object that represents one Point. It is NOT added to m_graphicsLinesFo...
Details for a specific Point.
virtual ~GraphicsScene()
Virtual destructor needed since using Q_OBJECT.
static double UNDEFINED_ORDINAL()
Get method for undefined ordinal constant.
void resetPositionHasChangedFlags()
Reset positionHasChanged flag for all items. Typically this is done as part of mousePressEvent.
QString QtCursorToString(Qt::CursorShape cursorShape)
Item type (i.e. image versus point)
Details for a specific Line.
void lineMembershipPurge(const CurveStyles &curveStyles, SplineDrawer &splineDrawer, QPainterPath &pathMultiValued, LineStyle &lineMultiValued)
Mark the end of addPoint calls. Remove stale lines, insert missing lines, and draw the graphics lines...
Graphics item for drawing a circular or polygonal Point.
void updateCurveStyles(const CurveStyles &modelCurveStyles)
Update curve styles after settings changed.
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
log4cpp::Category * mainCat
void resetOnLoad()
Reset, when loading a document after the first, to same state that first document was at when loaded...
void addTemporaryPoint(const QString &identifier, GraphicsPoint *point)
Add one temporary point to m_graphicsLinesForCurves. Non-temporary points are handled by the updateLi...
void updateCurveStyles(const CurveStyles &modelCurveStyles)
Update the curve style for every curve.
This class takes the output from Spline and uses that to draw the curve in the graphics window...
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
void resetOnLoad()
Reset, when loading a document after the first, to same state that first document was at when loaded...
void hideAllItemsExceptImage()
Hide all graphics items, except background image, in preparation for preview during IMPORT_TYPE_ADVAN...
void addRemoveCurves(GraphicsScene &scene, const QStringList &curveNames)
Add new curves and remove expired curves to match the specified list.
void showCurves(bool show, bool showAll=false, const QString &curveName="")
Show or hide all Curves (if showAll is true) or just the selected Curve (if showAll is false);...
void updateHighlightOpacity(double highlightOpacity)
Update the highlight opacity value. This may or may not affect the current display immediately depend...
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
const QString AXIS_CURVE_NAME
#define LOG4CPP_DEBUG_S(logger)