Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
GeometryWindow Class Reference

Window that displays the geometry information, as a table, for the current curve. More...

#include <GeometryWindow.h>

Inheritance diagram for GeometryWindow:
Inheritance graph
Collaboration diagram for GeometryWindow:
Collaboration graph

Public Slots

void slotPointHoverEnter (QString)
 Highlight the row for the specified point.
 
void slotPointHoverLeave (QString)
 Unhighlight the row for the specified point.
 

Signals

void signalGeometryWindowClosed ()
 Signal that this QDockWidget was just closed.
 

Public Member Functions

 GeometryWindow (MainWindow *mainWindow)
 Single constructor. Parent is needed or else this widget cannot be redocked after being undocked.
 
virtual ~GeometryWindow ()
 
virtual void clear ()
 Clear stale information.
 
virtual void closeEvent (QCloseEvent *event)
 Catch close event so corresponding menu item in MainWindow can be updated accordingly.
 
virtual void doCopy ()
 Copy the current selection to the clipboard.
 
virtual void update (const CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow, const QString &curveSelected, const Transformation &transformation)
 Populate the table with the specified Curve.
 
virtual QTableView * view () const
 QTableView-based class used by child class.
 
- Public Member Functions inherited from WindowAbstractBase
 WindowAbstractBase (QWidget *parent)
 Single constructor. Parent is needed or else this widget cannot be redocked after being undocked.
 
virtual ~WindowAbstractBase ()
 
void getTableStatus (bool &tableIsActive, bool &tableIsCopyable) const
 Give table status so MainWindow can determine if table can be copied.
 

Static Public Member Functions

static int columnBodyPointIdentifiers ()
 Hidden column that has the point identifiers.
 

Additional Inherited Members

Detailed Description

Window that displays the geometry information, as a table, for the current curve.

Column COLUMN_BODY_POINT_IDENTIFIERS is hidden. It contains the point identifiers so we can find the line associated with a point, and then highlight that line

Definition at line 28 of file GeometryWindow.h.

Constructor & Destructor Documentation

◆ GeometryWindow()

GeometryWindow::GeometryWindow ( MainWindow * mainWindow)

Single constructor. Parent is needed or else this widget cannot be redocked after being undocked.

Definition at line 22 of file GeometryWindow.cpp.

22 :
23 WindowAbstractBase (mainWindow)
24{
25 setVisible (false);
26 setAllowedAreas (Qt::AllDockWidgetAreas);
27 setWindowTitle (tr ("Geometry Window")); // Appears in title bar when undocked
28 setStatusTip (tr ("Geometry Window"));
29 setWhatsThis (tr ("Geometry Window\n\n"
30 "This table displays the following geometry data for the currently selected curve:\n\n"
31 "Function area = Area under the curve if it is a function\n\n"
32 "Polygon area = Area inside the curve if it is a relation. This value is only correct "
33 "if none of the curve lines intersect each other\n\n"
34 "X = X coordinate of each point\n\n"
35 "Y = Y coordinate of each point\n\n"
36 "Index = Point number\n\n"
37 "Distance = Distance along the curve in forward or backward direction, in either graph units "
38 "or as a percentage\n\n"
39 "If drag-and-drop is disabled, a rectangular set of cells may be selected by clicking and dragging. Otherwise, if "
40 "drag-and-drop is enabled, a rectangular set of cells may be selected using Click then Shift+Click, since click and drag "
41 "starts the dragging operation. Drag-and-drop mode is set in the Main Window settings"));
42
43 createWidgets (mainWindow);
44 loadStrategies();
45 initializeHeader ();
46}
const int INNER_RADIUS_MIN
Dockable widget abstract base class.

◆ ~GeometryWindow()

GeometryWindow::~GeometryWindow ( )
virtual

Definition at line 48 of file GeometryWindow.cpp.

49{
50 delete m_model;
51}

Member Function Documentation

◆ clear()

void GeometryWindow::clear ( )
virtual

Clear stale information.

Implements WindowAbstractBase.

Definition at line 53 of file GeometryWindow.cpp.

54{
55 // Resize table to remove stale body data
56 resizeTable (NUM_HEADER_ROWS);
57
58 // Clear stale header data values
59 for (int row = 0; row < NUM_HEADER_ROWS - 1; row++) {
60 m_model->setItem (row, COLUMN_HEADER_VALUE, new QStandardItem (""));
61 }
62}

◆ closeEvent()

void GeometryWindow::closeEvent ( QCloseEvent * event)
virtual

Catch close event so corresponding menu item in MainWindow can be updated accordingly.

Implements WindowAbstractBase.

Definition at line 64 of file GeometryWindow.cpp.

65{
66 LOG4CPP_INFO_S ((*mainCat)) << "GeometryWindow::closeEvent";
67
69}
log4cpp::Category * mainCat
Definition Logger.cpp:14
void signalGeometryWindowClosed()
Signal that this QDockWidget was just closed.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ columnBodyPointIdentifiers()

int GeometryWindow::columnBodyPointIdentifiers ( )
static

Hidden column that has the point identifiers.

Definition at line 71 of file GeometryWindow.cpp.

72{
73 return COLUMN_BODY_POINT_IDENTIFIERS;
74}

◆ doCopy()

void GeometryWindow::doCopy ( )
virtual

Copy the current selection to the clipboard.

Implements WindowAbstractBase.

Definition at line 87 of file GeometryWindow.cpp.

88{
89 LOG4CPP_INFO_S ((*mainCat)) << "GeometryWindow::doCopy";
90
91 QString text = m_model->selectionAsText (m_modelExport.delimiter());
92
93 if (!text.isEmpty ()) {
94
95 // Save to clipboard
96 QApplication::clipboard ()->setText (text);
97
98 }
99}
ExportDelimiter delimiter() const
Get method for delimiter.
QString selectionAsText(ExportDelimiter delimiter) const
Convert the selection into exportable text which is good for text editors.

◆ signalGeometryWindowClosed

void GeometryWindow::signalGeometryWindowClosed ( )
signal

Signal that this QDockWidget was just closed.

◆ slotPointHoverEnter

void GeometryWindow::slotPointHoverEnter ( QString pointIdentifier)
slot

Highlight the row for the specified point.

Definition at line 135 of file GeometryWindow.cpp.

136{
138}
void setCurrentPointIdentifier(const QString &pointIdentifier)
Set the point identifier to be highlighted. Value is empty for no highlighting.

◆ slotPointHoverLeave

void GeometryWindow::slotPointHoverLeave ( QString )
slot

Unhighlight the row for the specified point.

Definition at line 140 of file GeometryWindow.cpp.

141{
142 m_model->setCurrentPointIdentifier ("");
143}

◆ update()

void GeometryWindow::update ( const CmdMediator & cmdMediator,
const MainWindowModel & modelMainWindow,
const QString & curveSelected,
const Transformation & transformation )
virtual

Populate the table with the specified Curve.

Implements WindowAbstractBase.

Definition at line 192 of file GeometryWindow.cpp.

196{
197 LOG4CPP_INFO_S ((*mainCat)) << "GeometryWindow::update";
198
199 const int NUM_LEGEND_ROWS_UNSPANNED = 2; // Match with GeometryModel::NUM_LEGEND_ROWS_UNSPANNED
200
201 // Save inputs
202 m_modelExport = cmdMediator.document().modelExport();
203 m_model->setDelimiter (m_modelExport.delimiter());
204 m_view->setDragEnabled (modelMainWindow.dragDropExport());
205
206 // Gather and calculate geometry data
207 const Curve *curve = cmdMediator.document().curveForCurveName (curveSelected);
208
210
211 const Points points = curve->points();
212
216
217 CurveStyle curveStyle = cmdMediator.document().modelCurveStyles().curveStyle (curveSelected);
218 m_geometryStrategyContext.calculateGeometry (points,
219 cmdMediator.document().modelCoords(),
220 cmdMediator.document().modelGeneral(),
221 modelMainWindow,
222 transformation,
223 curveStyle.lineStyle().curveConnectAs(),
224 funcArea,
225 polyArea,
226 x,
227 y,
233
234 // Was there a potential export ambiguity
235 bool wasAmbiguity = isPotentialExportAmbiguity.contains (true);
236
237 // Unmerge any merged cells from the previous update
238 m_view->clearSpans();
239
240 // Output to table
241 resizeTable (NUM_HEADER_ROWS + points.count() + (wasAmbiguity ? NUM_LEGEND_ROWS_UNSPANNED : 0));
242
243 m_model->setItem (HEADER_ROW_NAME, COLUMN_HEADER_VALUE, new QStandardItem (curveSelected));
244 m_model->setItem (HEADER_ROW_FUNC_AREA, COLUMN_HEADER_VALUE, new QStandardItem (funcArea));
245 m_model->setItem (HEADER_ROW_POLY_AREA, COLUMN_HEADER_VALUE, new QStandardItem (polyArea));
246
247 if (transformation.transformIsDefined()) {
248
250
251 int row = NUM_HEADER_ROWS;
252 for (int index = 0; index < points.count(); row++, index++) {
253
254 const Point &point = points.at (index);
255
256 QPointF posGraph;
257 transformation.transformScreenToRawGraph (point.posScreen (),
258 posGraph);
259
260 m_model->setItem (row, COLUMN_BODY_X, new QStandardItem (x [index]));
261 m_model->setItem (row, COLUMN_BODY_Y, new QStandardItem (y [index]));
262 m_model->setItem (row, COLUMN_BODY_INDEX, new QStandardItem (QString::number (index + 1)));
263 m_model->setItem (row, COLUMN_BODY_DISTANCE_GRAPH_FORWARD, new QStandardItem (distanceGraphForward [index]));
264 m_model->setItem (row, COLUMN_BODY_DISTANCE_PERCENT_FORWARD, new QStandardItem (distancePercentForward [index]));
265 m_model->setItem (row, COLUMN_BODY_DISTANCE_GRAPH_BACKWARD, new QStandardItem (distanceGraphBackward [index]));
266 m_model->setItem (row, COLUMN_BODY_DISTANCE_PERCENT_BACKWARD, new QStandardItem (distancePercentBackward [index]));
267 m_model->setItem (row, COLUMN_BODY_POINT_IDENTIFIERS, new QStandardItem (point.identifier()));
268 }
269
270 if (wasAmbiguity) {
271 // Merge row into one big cell so text fits. Requires unmerge at start of next update
272 m_view->setSpan (row, 0, NUM_LEGEND_ROWS_UNSPANNED, NUM_BODY_COLUMNS);
273 m_model->setItem (row, COLUMN_BODY_X,
274 new QStandardItem (tr ("Highlighted segments may have unexpected values when exported due to overlaps. "
275 "Adjust points or change Settings / Curve Properties / Connect As.")));
276 row++;
277 }
278 }
279
280 // Unselect everything
281 unselectAll ();
282
283 // Make sure the hidden column stays hidden
284 m_view->setColumnHidden (COLUMN_BODY_POINT_IDENTIFIERS, true);
285}
#define ENGAUGE_CHECK_PTR(ptr)
#endif
QList< Point > Points
Definition Points.h:13
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Container for LineStyle and PointStyle for one Curve.
Definition CurveStyle.h:19
LineStyle lineStyle() const
Get method for LineStyle.
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
Container for one set of digitized Points.
Definition Curve.h:34
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition Document.cpp:723
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:695
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
Definition Document.cpp:702
DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
Definition Document.cpp:716
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
Definition Document.cpp:335
void setPotentialExportAmbiguity(const QVector< bool > &isPotentialExportAmbiguity)
Remember which rows could have ambiguities during export - these will be highlighted.
void calculateGeometry(const Points &points, const DocumentModelCoords &modelCoords, const DocumentModelGeneral &modelGeneral, const MainWindowModel &modelMainWindow, const Transformation &transformation, CurveConnectAs connectAs, QString &funcArea, QString &polyArea, QVector< QString > &x, QVector< QString > &y, QVector< bool > &isPotentialExportAmbiguity, QVector< QString > &distanceGraphForward, QVector< QString > &distancePercentForward, QVector< QString > &distanceGraphBackward, QVector< QString > &distancePercentBackward) const
Calculate geometry parameters.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Definition LineStyle.cpp:63
bool dragDropExport() const
Get method for drag and drop export.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition Point.h:26
QPointF posScreen() const
Accessor for screen position.
Definition Point.cpp:404
QString identifier() const
Unique identifier for a specific Point.
Definition Point.cpp:268
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.
void setDelimiter(ExportDelimiter delimiter)
Save output delimiter.

◆ view()

QTableView * GeometryWindow::view ( ) const
virtual

QTableView-based class used by child class.

Implements WindowAbstractBase.

Definition at line 287 of file GeometryWindow.cpp.

288{
289 return dynamic_cast<QTableView*> (m_view);
290}

The documentation for this class was generated from the following files: