23#include <QApplication>
24#include <QGraphicsItem>
30 QGraphicsScene(mainWindow),
31 m_pathItemMultiValued (nullptr)
43 <<
" identifier=" << 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();
94QString 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);
127const 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) {
182 m_graphicsLinesForCurves.printStream (indentation,
188 LOG4CPP_INFO_S ((*
mainCat)) <<
"GraphicsScene::removePoint identifier=" << identifier.toLatin1().data();
190 m_graphicsLinesForCurves.removePoint (identifier);
197 m_graphicsLinesForCurves.removeTemporaryPointIfExists ();
209 int itemsBefore = items().count();
211 m_graphicsLinesForCurves.resetOnLoad();
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,
283 m_graphicsLinesForCurves.updateHighlightOpacity (highlightOpacity);
285 updateCurves (cmdMediator);
288 updatePointMembership (cmdMediator,
293void GraphicsScene::updateCurves (
CmdMediator &cmdMediator)
298 QStringList curveNames;
310 m_graphicsLinesForCurves.updateCurveStyles (modelCurveStyles);
321 m_graphicsLinesForCurves.updatePointOrdinalsAfterDrag (curveStyles,
326 QPainterPath pathMultiValued;
328 m_graphicsLinesForCurves.updateGraphicsLinesToMatchGraphicsPoints (curveStyles,
333 updatePathItemMultiValued (pathMultiValued,
338void 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"));
355void GraphicsScene::updatePointMembership (
CmdMediator &cmdMediator,
361 CallbackSceneUpdateAfterCommand ftor (m_graphicsLinesForCurves,
365 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
370 m_graphicsLinesForCurves.lineMembershipReset ();
380 SplineDrawer splineDrawer (transformation);
381 QPainterPath pathMultiValued;
382 LineStyle lineMultiValued;
387 updatePathItemMultiValued (pathMultiValued,
const QString AXIS_CURVE_NAME
@ DATA_KEY_POSITION_HAS_CHANGED
@ DATA_KEY_GRAPHICS_ITEM_TYPE
@ GRAPHICS_ITEM_TYPE_IMAGE
@ GRAPHICS_ITEM_TYPE_LINE
@ GRAPHICS_ITEM_TYPE_POINT
log4cpp::Category * mainCat
QString QtCursorToString(Qt::CursorShape cursorShape)
CallbackSearchReturn callback(const QString &, const Point &point)
Callback method.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
Window that displays the geometry information, as a table, for the current curve.
void addRemoveCurves(GraphicsScene &scene, const QStringList &curveNames)
Add new curves and remove expired curves to match the specified list.
Factor for generating GraphicsPointAbstractBase class objects.
GraphicsPoint * createPoint(QGraphicsScene &scene, const QString &identifier, const QPointF &posScreen, const PointStyle &pointStyle, GeometryWindow *geometryWindow)
Create circle or polygon point according to the PointStyle.
Graphics item for drawing a circular or polygonal Point.
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
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 &modelCurveStyles, const Transformation &transformation)
A mouse move has just occurred so move the selected points, since they were dragged.
void resetOnLoad()
Reset, when loading a document after the first, to same state that first document was at when loaded.
void removeTemporaryScaleBarIfExists()
Remove temporary scale bar, composed of two points and the line between them.
GraphicsScene(MainWindow *mainWindow)
Single constructor.
virtual ~GraphicsScene()
Virtual destructor needed since using Q_OBJECT.
void updateAfterCommand(CmdMediator &cmdMediator, double highlightOpacity, GeometryWindow *geometryWindow, const Transformation &transformation)
Update the Points and their Curves after executing a command.
void hideAllItemsExceptImage()
Hide all graphics items, except background image, in preparation for preview during IMPORT_TYPE_ADVAN...
void addTemporaryPoint(const QString &identifier, GraphicsPoint *point)
Add one temporary point to m_graphicsLinesForCurves. Non-temporary points are handled by the updateLi...
void addTemporaryScaleBar(GraphicsPoint *point0, GraphicsPoint *point1, const QString &pointIdentifier0, const QString &pointIdentifier1)
Add temporary scale bar to scene.
QStringList positionHasChangedPointIdentifiers() const
Return a list of identifiers for the points that have moved since the last call to resetPositionHasCh...
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 resetPositionHasChangedFlags()
Reset positionHasChanged flag for all items. Typically this is done as part of mousePressEvent.
void printStream(QString indentation, QTextStream &str)
Debugging method that supports print method of this class and printStream method of some other class(...
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
void updateCurveStyles(const CurveStyles &modelCurveStyles)
Update curve styles after settings changed.
Details for a specific Line.
unsigned int width() const
Width of line.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Details for a specific Point.
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
static double UNDEFINED_ORDINAL()
Get method for undefined ordinal constant.
This class takes the output from Spline and uses that to draw the curve in the graphics window,...
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)