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 QString &pointIdentifier0,
48 const QString &pointIdentifier1)
50 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::addTemporaryScaleBar";
52 const double ORDINAL_0 = 0, ORDINAL_1 = 1;
54 m_graphicsLinesForCurves.
addPoint (AXIS_CURVE_NAME,
58 m_graphicsLinesForCurves.
addPoint (AXIS_CURVE_NAME,
66 const QPointF &posScreen,
69 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::createPoint" 70 <<
" identifier=" << identifier.toLatin1().
data();
83 point->
setData (DATA_KEY_GRAPHICS_ITEM_TYPE, GRAPHICS_ITEM_TYPE_POINT);
88 QString GraphicsScene::dumpCursors ()
const 90 QString cursorOverride = (QApplication::overrideCursor () != 0) ?
91 QtCursorToString (QApplication::overrideCursor ()->shape ()) :
93 QString cursorImage = QtCursorToString (image()->cursor().shape ());
95 QString dump = QString (
"overrideCursor=%1 imageCursor=%2")
104 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::hideAllItemsExceptImage";
106 for (
int index = 0; index < QGraphicsScene::items().count(); index++) {
107 QGraphicsItem *item = QGraphicsScene::items().at(index);
109 if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt() == GRAPHICS_ITEM_TYPE_IMAGE) {
121 const QGraphicsPixmapItem *GraphicsScene::image ()
const 124 QList<QGraphicsItem*> items = QGraphicsScene::items();
125 QList<QGraphicsItem*>::iterator itr;
126 for (itr = items.begin(); itr != items.end(); itr++) {
128 QGraphicsItem* item = *itr;
129 if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_IMAGE) {
131 return (QGraphicsPixmapItem *) item;
140 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::positionHasChangedPointIdentifiers";
142 QStringList movedIds;
144 const QList<QGraphicsItem*> &items = QGraphicsScene::items();
145 QList<QGraphicsItem*>::const_iterator itr;
146 for (itr = items.begin(); itr != items.end(); itr++) {
148 const QGraphicsItem *item = *itr;
151 bool isPoint = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT);
154 QString identifier = item->data (DATA_KEY_IDENTIFIER).toString ();
155 bool positionHasChanged = item->data (DATA_KEY_POSITION_HAS_CHANGED).toBool ();
157 LOG4CPP_DEBUG_S ((*mainCat)) <<
"GraphicsScene::positionHasChangedPointIdentifiers" 158 <<
" identifier=" << identifier.toLatin1().data()
159 <<
" positionHasChanged=" << (positionHasChanged ?
"yes" :
"no");
161 if (isPoint && positionHasChanged) {
164 movedIds << item->data(DATA_KEY_IDENTIFIER).toString ();
182 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::removePoint identifier=" << identifier.toLatin1().data();
189 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::removeTemporaryPointIfExists";
196 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::removeTemporaryScaleBarIfExists";
203 int itemsBefore = items().count();
207 int itemsAfter = items().count();
209 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::resetOnLoad" 210 <<
" itemsBefore=" << itemsBefore
211 <<
" itemsAfter=" << itemsAfter;
216 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::resetPositionHasChangedFlags";
218 QList<QGraphicsItem*> itms = items ();
219 QList<QGraphicsItem*>::const_iterator itr;
220 for (itr = itms.begin (); itr != itms.end (); itr++) {
222 QGraphicsItem *item = *itr;
223 item->setData (DATA_KEY_POSITION_HAS_CHANGED,
false);
229 const QString &curveNameWanted)
231 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::showCurves" 232 <<
" show=" << (show ?
"true" :
"false")
233 <<
" showAll=" << (showAll ?
"true" :
"false")
234 <<
" curve=" << curveNameWanted.toLatin1().data();
236 const QList<QGraphicsItem*> &items = QGraphicsScene::items();
237 QList<QGraphicsItem*>::const_iterator itr;
238 for (itr = items.begin(); itr != items.end(); itr++) {
240 QGraphicsItem* item = *itr;
243 bool isPoint = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT);
244 bool isCurve = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_LINE);
246 if (isPoint || isCurve) {
248 bool showThis = show;
249 if (show && !showAll) {
250 QString identifier = item->data (DATA_KEY_IDENTIFIER).toString ();
255 showThis = (curveNameWanted == curveNameGot);
259 showThis = (curveNameWanted == identifier);
264 item->setVisible (showThis);
271 double highlightOpacity,
274 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateAfterCommand";
278 updateCurves (cmdMediator);
281 updatePointMembership (cmdMediator,
285 void GraphicsScene::updateCurves (
CmdMediator &cmdMediator)
287 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateCurves";
290 QStringList curveNames;
291 curveNames << AXIS_CURVE_NAME;
300 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateCurveStyles";
308 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updateGraphicsLinesToMatchGraphicsPoints";
321 void GraphicsScene::updatePointMembership (
CmdMediator &cmdMediator,
324 LOG4CPP_INFO_S ((*mainCat)) <<
"GraphicsScene::updatePointMembership";
330 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) 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.
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.
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
void updateAfterCommand(CmdMediator &cmdMediator, double highlightOpacity, GeometryWindow *geometryWindow)
Update the Points and their Curves after executing a command.
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.
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.
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.
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.
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.
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.
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...