7 #include "CallbackSceneUpdateAfterCommand.h" 9 #include "CurvesGraphs.h" 10 #include "CurveStyles.h" 12 #include "EngaugeAssert.h" 13 #include "EnumsToQt.h" 14 #include "GeometryWindow.h" 15 #include "GraphicsItemType.h" 16 #include "GraphicsPoint.h" 17 #include "GraphicsPointFactory.h" 18 #include "GraphicsScene.h" 20 #include "MainWindow.h" 22 #include "PointStyle.h" 23 #include <QApplication> 24 #include <QGraphicsItem> 25 #include "QtToString.h" 26 #include "Transformation.h" 29 QGraphicsScene(mainWindow)
36 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::addTemporaryPoint" 37 <<
" identifer=" << identifier.toLatin1().data();
39 m_graphicsLinesForCurves.
addPoint (AXIS_CURVE_NAME,
47 const QPointF &posScreen,
50 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::createPoint" 51 <<
" identifier=" << identifier.toLatin1().
data();
64 point->
setData (DATA_KEY_GRAPHICS_ITEM_TYPE, GRAPHICS_ITEM_TYPE_POINT);
69 QString GraphicsScene::dumpCursors ()
const 71 QString cursorOverride = (QApplication::overrideCursor () != 0) ?
72 QtCursorToString (QApplication::overrideCursor ()->shape ()) :
74 QString cursorImage = QtCursorToString (image()->cursor().shape ());
76 QString dump = QString (
"overrideCursor=%1 imageCursor=%2")
85 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::hideAllItemsExceptImage";
87 for (
int index = 0; index < QGraphicsScene::items().count(); index++) {
88 QGraphicsItem *item = QGraphicsScene::items().at(index);
90 if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt() == GRAPHICS_ITEM_TYPE_IMAGE) {
102 const QGraphicsPixmapItem *GraphicsScene::image ()
const 105 QList<QGraphicsItem*> items = QGraphicsScene::items();
106 QList<QGraphicsItem*>::iterator itr;
107 for (itr = items.begin(); itr != items.end(); itr++) {
109 QGraphicsItem* item = *itr;
110 if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_IMAGE) {
112 return (QGraphicsPixmapItem *) item;
121 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::positionHasChangedPointIdentifiers";
123 QStringList movedIds;
125 const QList<QGraphicsItem*> &items = QGraphicsScene::items();
126 QList<QGraphicsItem*>::const_iterator itr;
127 for (itr = items.begin(); itr != items.end(); itr++) {
129 const QGraphicsItem *item = *itr;
132 bool isPoint = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT);
135 QString identifier = item->data (DATA_KEY_IDENTIFIER).toString ();
136 bool positionHasChanged = item->data (DATA_KEY_POSITION_HAS_CHANGED).toBool ();
138 LOG4CPP_DEBUG_S ((*mainCat)) <<
"GraphicsScene::positionHasChangedPointIdentifiers" 139 <<
" identifier=" << identifier.toLatin1().data()
140 <<
" positionHasChanged=" << (positionHasChanged ?
"yes" :
"no");
142 if (isPoint && positionHasChanged) {
145 movedIds << item->data(DATA_KEY_IDENTIFIER).toString ();
163 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::removePoint identifier=" << identifier.toLatin1().data();
170 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::removeTemporaryPointIfExists";
179 int itemsBefore = items().count();
183 int itemsAfter = items().count();
185 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::resetOnLoad" 186 <<
" itemsBefore=" << itemsBefore
187 <<
" itemsAfter=" << itemsAfter;
192 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::resetPositionHasChangedFlags";
194 QList<QGraphicsItem*> itms = items ();
195 QList<QGraphicsItem*>::const_iterator itr;
196 for (itr = itms.begin (); itr != itms.end (); itr++) {
198 QGraphicsItem *item = *itr;
199 item->setData (DATA_KEY_POSITION_HAS_CHANGED,
false);
205 const QString &curveNameWanted)
207 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::showCurves" 208 <<
" show=" << (show ?
"true" :
"false")
209 <<
" showAll=" << (showAll ?
"true" :
"false")
210 <<
" curve=" << curveNameWanted.toLatin1().data();
212 const QList<QGraphicsItem*> &items = QGraphicsScene::items();
213 QList<QGraphicsItem*>::const_iterator itr;
214 for (itr = items.begin(); itr != items.end(); itr++) {
216 QGraphicsItem* item = *itr;
219 bool isPoint = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT);
220 bool isCurve = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_LINE);
222 if (isPoint || isCurve) {
224 bool showThis = show;
225 if (show && !showAll) {
226 QString identifier = item->data (DATA_KEY_IDENTIFIER).toString ();
231 showThis = (curveNameWanted == curveNameGot);
235 showThis = (curveNameWanted == identifier);
240 item->setVisible (showThis);
247 double highlightOpacity,
250 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateAfterCommand";
254 updateCurves (cmdMediator);
257 updatePointMembership (cmdMediator,
261 void GraphicsScene::updateCurves (
CmdMediator &cmdMediator)
263 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateCurves";
266 QStringList curveNames;
267 curveNames << AXIS_CURVE_NAME;
276 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateCurveStyles";
284 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateGraphicsLinesToMatchGraphicsPoints";
297 void GraphicsScene::updatePointMembership (
CmdMediator &cmdMediator,
300 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updatePointMembership";
306 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
void updateGraphicsLinesToMatchGraphicsPoints(const CurveStyles &modelCurveStyles, const Transformation &transformation)
A mouse move has just occurred so move the selected points, since they were dragged.
void lineMembershipPurge(const CurveStyles &curveStyles)
Mark the end of addPoint calls. Remove stale lines, insert missing lines, and draw the graphics lines...
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)
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.
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 updateAfterCommand(CmdMediator &cmdMediator, double highlightOpacity, GeometryWindow *geometryWindow)
Update the Points and their Curves after executing a command.
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
Window that displays the geometry information, as a table, for the current curve. ...
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
CallbackSearchReturn callback(const QString &, const Point &point)
Callback method.
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...
void updateGraphicsLinesToMatchGraphicsPoints(const CurveStyles &curveStyles)
Calls to moveLinesWithDraggedPoint have finished so update the lines correspondingly.
Details for a specific Point.
QStringList positionHasChangedPointIdentifiers() const
Return a list of identifiers for the points that have moved since the last call to resetPositionHasCh...
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
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.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Graphics item for drawing a circular or polygonal Point.
void updateCurveStyles(const CurveStyles &modelCurveStyles)
Update curve styles after settings changed.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
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.
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
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...
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...