Engauge Digitizer 2
|
Add point and line handling to generic QGraphicsScene. More...
#include <GraphicsScene.h>
Public Member Functions | |
GraphicsScene (MainWindow *mainWindow) | |
Single constructor. | |
virtual | ~GraphicsScene () |
Virtual destructor needed since using Q_OBJECT. | |
void | addTemporaryPoint (const QString &identifier, GraphicsPoint *point) |
Add one temporary point to m_graphicsLinesForCurves. Non-temporary points are handled by the updateLineMembership functions. | |
void | addTemporaryScaleBar (GraphicsPoint *point0, GraphicsPoint *point1, const QString &pointIdentifier0, const QString &pointIdentifier1) |
Add temporary scale bar to scene. | |
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_graphicsLinesForCurves (see addPoint) | |
void | hideAllItemsExceptImage () |
Hide all graphics items, except background image, in preparation for preview during IMPORT_TYPE_ADVANCED. | |
QStringList | positionHasChangedPointIdentifiers () const |
Return a list of identifiers for the points that have moved since the last call to resetPositionHasChanged. | |
void | printStream (QString indentation, QTextStream &str) |
Debugging method that supports print method of this class and printStream method of some other class(es) | |
void | removePoint (const QString &identifier) |
Remove specified point. This aborts if the point does not exist. | |
void | removeTemporaryPointIfExists () |
Remove temporary point if it exists. | |
void | removeTemporaryScaleBarIfExists () |
Remove temporary scale bar, composed of two points and the line between them. | |
void | resetOnLoad () |
Reset, when loading a document after the first, to same state that first document was at when loaded. | |
void | resetPositionHasChangedFlags () |
Reset positionHasChanged flag for all items. Typically this is done as part of mousePressEvent. | |
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 | updateAfterCommand (CmdMediator &cmdMediator, double highlightOpacity, GeometryWindow *geometryWindow, const Transformation &transformation) |
Update the Points and their Curves after executing a command. | |
void | updateCurveStyles (const CurveStyles &modelCurveStyles) |
Update curve styles after settings changed. | |
void | updateGraphicsLinesToMatchGraphicsPoints (const CurveStyles &modelCurveStyles, const Transformation &transformation) |
A mouse move has just occurred so move the selected points, since they were dragged. | |
Add point and line handling to generic QGraphicsScene.
The primary tasks are:
This class stores points and lines as QGraphicsItems, but also maintains identifier-to-QGraphicsItems mappings to the points and lines are accessible for updates (like when dragging points around and we need to update the attached lines).
Definition at line 36 of file GraphicsScene.h.
GraphicsScene::GraphicsScene | ( | MainWindow * | mainWindow | ) |
Single constructor.
Definition at line 29 of file GraphicsScene.cpp.
|
virtual |
Virtual destructor needed since using Q_OBJECT.
Definition at line 35 of file GraphicsScene.cpp.
void GraphicsScene::addTemporaryPoint | ( | const QString & | identifier, |
GraphicsPoint * | point ) |
Add one temporary point to m_graphicsLinesForCurves. Non-temporary points are handled by the updateLineMembership functions.
Definition at line 39 of file GraphicsScene.cpp.
void GraphicsScene::addTemporaryScaleBar | ( | GraphicsPoint * | point0, |
GraphicsPoint * | point1, | ||
const QString & | pointIdentifier0, | ||
const QString & | pointIdentifier1 ) |
Add temporary scale bar to scene.
The scale bar is different from points and lines (always a complete set of 2 points and one line, and drawn using different point and line styles) that it is handled outside m_graphisLinesForCurves
Definition at line 51 of file GraphicsScene.cpp.
GraphicsPoint * GraphicsScene::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_graphicsLinesForCurves (see addPoint)
Definition at line 70 of file GraphicsScene.cpp.
void GraphicsScene::hideAllItemsExceptImage | ( | ) |
Hide all graphics items, except background image, in preparation for preview during IMPORT_TYPE_ADVANCED.
Definition at line 108 of file GraphicsScene.cpp.
QStringList GraphicsScene::positionHasChangedPointIdentifiers | ( | ) | const |
Return a list of identifiers for the points that have moved since the last call to resetPositionHasChanged.
Definition at line 144 of file GraphicsScene.cpp.
void GraphicsScene::printStream | ( | QString | indentation, |
QTextStream & | str ) |
Debugging method that supports print method of this class and printStream method of some other class(es)
Definition at line 179 of file GraphicsScene.cpp.
Remove specified point. This aborts if the point does not exist.
Definition at line 186 of file GraphicsScene.cpp.
void GraphicsScene::removeTemporaryPointIfExists | ( | ) |
Remove temporary point if it exists.
Temporary point handling is so complicated that this method quietly allows redundant calls to this method, without complaining that the point has already been removed when called again
Definition at line 193 of file GraphicsScene.cpp.
void GraphicsScene::removeTemporaryScaleBarIfExists | ( | ) |
Remove temporary scale bar, composed of two points and the line between them.
Definition at line 200 of file GraphicsScene.cpp.
void GraphicsScene::resetOnLoad | ( | ) |
Reset, when loading a document after the first, to same state that first document was at when loaded.
Definition at line 205 of file GraphicsScene.cpp.
void GraphicsScene::resetPositionHasChangedFlags | ( | ) |
Reset positionHasChanged flag for all items. Typically this is done as part of mousePressEvent.
Definition at line 220 of file GraphicsScene.cpp.
Show or hide all Curves (if showAll is true) or just the selected Curve (if showAll is false);.
Definition at line 233 of file GraphicsScene.cpp.
void GraphicsScene::updateAfterCommand | ( | CmdMediator & | cmdMediator, |
double | highlightOpacity, | ||
GeometryWindow * | geometryWindow, | ||
const Transformation & | transformation ) |
Update the Points and their Curves after executing a command.
After a mouse drag, the lines are already updated and updating would be done on out of date information (since that would be brought up to date by the NEXT command)
Definition at line 276 of file GraphicsScene.cpp.
void GraphicsScene::updateCurveStyles | ( | const CurveStyles & | modelCurveStyles | ) |
Update curve styles after settings changed.
Definition at line 306 of file GraphicsScene.cpp.
void GraphicsScene::updateGraphicsLinesToMatchGraphicsPoints | ( | const CurveStyles & | modelCurveStyles, |
const Transformation & | transformation ) |
A mouse move has just occurred so move the selected points, since they were dragged.
The transformation is needed so the screen coordinates can be converted to graph coordinates when updating point ordinals
Definition at line 313 of file GraphicsScene.cpp.