Skip to content

Commit

Permalink
Clean up of z values for issue #154
Browse files Browse the repository at this point in the history
  • Loading branch information
markummitchell-tu committed Jul 7, 2016
1 parent ca7e98d commit 4d6303a
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dev/engauge.pro.user.mmitchell.linux
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2016-06-30T00:57:57. -->
<!-- Written by QtCreator 3.0.1, 2016-07-06T22:13:50. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down
6 changes: 4 additions & 2 deletions engauge.pro
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ HEADERS += \
src/Zoom/ZoomControl.h \
src/Zoom/ZoomFactor.h \
src/Zoom/ZoomFactorInitial.h \
src/Zoom/ZoomLabels.h
src/Zoom/ZoomLabels.h \
src/util/ZValues.h

SOURCES += \
src/Background/BackgroundImage.cpp \
Expand Down Expand Up @@ -610,7 +611,8 @@ SOURCES += \
src/View/ViewProfileScale.cpp \
src/View/ViewSegmentFilter.cpp \
src/util/Xml.cpp \
src/Zoom/ZoomLabels.cpp
src/Zoom/ZoomLabels.cpp \
src/util/ZValues.cpp

macx-* {
CONFIG(debug,debug|release){
Expand Down
3 changes: 1 addition & 2 deletions src/Background/BackgroundStateAbstractBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#include "GraphicsItemType.h"
#include "GraphicsScene.h"
#include "Logger.h"
#include "ZValues.h"

BackgroundStateAbstractBase::BackgroundStateAbstractBase(BackgroundStateContext &context,
GraphicsScene &scene) :
m_context (context),
m_scene (scene),
m_imageItem (0)
{
const int Z_VALUE_BACKGROUND = 0;

// Create an image but do not show it until the appropriate state is reached
QPixmap dummy;
m_imageItem = m_scene.addPixmap (dummy);
Expand Down
2 changes: 2 additions & 0 deletions src/Graphics/GraphicsLinesForCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "QtToString.h"
#include "Spline.h"
#include "Transformation.h"
#include "ZValues.h"

using namespace std;

Expand All @@ -30,6 +31,7 @@ typedef QMap<double, double> XOrThetaToOrdinal;
GraphicsLinesForCurve::GraphicsLinesForCurve(const QString &curveName) :
m_curveName (curveName)
{
setZValue (Z_VALUE_CURVE);
setData (DATA_KEY_GRAPHICS_ITEM_TYPE,
GRAPHICS_ITEM_TYPE_LINE);
setData (DATA_KEY_IDENTIFIER,
Expand Down
6 changes: 3 additions & 3 deletions src/Graphics/GraphicsPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include <QPen>
#include <QTextStream>
#include "QtToString.h"
#include "ZValues.h"

const double ZERO_WIDTH = 0.0;
const double Z_VALUE = 100.0; // Put on top of Segments in DlgSettingsSegments

GraphicsPoint::GraphicsPoint(QGraphicsScene &scene,
const QString &identifier,
Expand Down Expand Up @@ -112,7 +112,7 @@ void GraphicsPoint::createPointEllipse (unsigned int radius)
2 * radiusSigned + 1));
m_scene.addItem (m_graphicsItemEllipse);

m_graphicsItemEllipse->setZValue (Z_VALUE);
m_graphicsItemEllipse->setZValue (Z_VALUE_POINT);
m_graphicsItemEllipse->setData (DATA_KEY_IDENTIFIER, m_identifier);
m_graphicsItemEllipse->setData (DATA_KEY_GRAPHICS_ITEM_TYPE, GRAPHICS_ITEM_TYPE_POINT);
m_graphicsItemEllipse->setPos (m_posScreen.x (),
Expand Down Expand Up @@ -147,7 +147,7 @@ void GraphicsPoint::createPointPolygon (const QPolygonF &polygon)
polygon);
m_scene.addItem (m_graphicsItemPolygon);

m_graphicsItemPolygon->setZValue (Z_VALUE);
m_graphicsItemPolygon->setZValue (Z_VALUE_POINT);
m_graphicsItemPolygon->setData (DATA_KEY_IDENTIFIER, m_identifier);
m_graphicsItemPolygon->setData (DATA_KEY_GRAPHICS_ITEM_TYPE, GRAPHICS_ITEM_TYPE_POINT);
m_graphicsItemPolygon->setPos (m_posScreen.x (),
Expand Down
5 changes: 2 additions & 3 deletions src/Segment/SegmentLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include <QPen>
#include "Segment.h"
#include "SegmentLine.h"

const double ZVALUE_SEGMENT = 50; // Less than z value for GraphicsPoint
#include "ZValues.h"

SegmentLine::SegmentLine(QGraphicsScene &scene,
const DocumentModelSegments &modelSegments,
Expand All @@ -29,7 +28,7 @@ SegmentLine::SegmentLine(QGraphicsScene &scene,
// Make this transparent now, but always visible so hover events work
scene.addItem (this);
setPen (QPen (Qt::transparent));
setZValue (ZVALUE_SEGMENT);
setZValue (Z_VALUE_CURVE);
setVisible (true);
setAcceptHoverEvents (true);
setHover (false); // Initially the cursor is not hovering over this object. Later a hover event will change this state
Expand Down
6 changes: 4 additions & 2 deletions src/engauge_test_template.pro
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ HEADERS += \
Zoom/ZoomControl.h \
Zoom/ZoomFactor.h \
Zoom/ZoomFactorInitial.h\
Zoom/ZoomLabels.h
Zoom/ZoomLabels.h \
util/ZValues.h

SOURCES += \
Background/BackgroundImage.cpp \
Expand Down Expand Up @@ -593,7 +594,8 @@ SOURCES += \
View/ViewProfileScale.cpp \
View/ViewSegmentFilter.cpp \
util/Xml.cpp \
Zoom/ZoomLabels.cpp
Zoom/ZoomLabels.cpp \
util/ZValues.cpp

TARGET = ../bin/TEST

Expand Down
13 changes: 13 additions & 0 deletions src/util/ZValues.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/******************************************************************************************************
* (C) 2016 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
******************************************************************************************************/

#include "ZValues.h"

const int Z_VALUE_BACKGROUND = 0;
const int Z_VALUE_GRID_LINE = 100;
const int Z_VALUE_CURVE = 200;
const int Z_VALUE_POINT = 300;

16 changes: 16 additions & 0 deletions src/util/ZValues.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/******************************************************************************************************
* (C) 2016 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
******************************************************************************************************/

#ifndef Z_VALUES_H
#define Z_VALUES_H

/// Z values for ordering of the various graphics layers, with background at the bottom
extern const int Z_VALUE_BACKGROUND;
extern const int Z_VALUE_CURVE;
extern const int Z_VALUE_GRID;
extern const int Z_VALUE_POINT;

#endif // Z_VALUES_H

0 comments on commit 4d6303a

Please sign in to comment.