7 #include "CmdMediator.h" 9 #include "CurveConnectAs.h" 10 #include "CurveStyle.h" 11 #include "EngaugeAssert.h" 12 #include "GeometryModel.h" 13 #include "GeometryWindow.h" 15 #include "MainWindow.h" 16 #include <QApplication> 18 #include <QItemSelectionModel> 19 #include <QTextStream> 20 #include "WindowTable.h" 26 setAllowedAreas (Qt::AllDockWidgetAreas);
27 setWindowTitle (tr (
"Geometry Window"));
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"));
43 createWidgets (mainWindow);
48 GeometryWindow::~GeometryWindow()
56 resizeTable (NUM_HEADER_ROWS);
59 for (
int row = 0; row < NUM_HEADER_ROWS - 1; row++) {
60 m_model->setItem (row, COLUMN_HEADER_VALUE,
new QStandardItem (
""));
66 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryWindow::closeEvent";
73 return COLUMN_BODY_POINT_IDENTIFIERS;
76 void GeometryWindow::createWidgets (
MainWindow *mainWindow)
81 connect (m_view, SIGNAL (signalTableStatusChange ()),
82 mainWindow, SLOT (slotTableStatusChange ()));
89 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryWindow::doCopy";
93 if (!text.isEmpty ()) {
96 QApplication::clipboard ()->setText (text);
101 void GeometryWindow::initializeHeader ()
103 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryWindow::initializeHeader";
105 resizeTable (NUM_HEADER_ROWS);
107 m_model->setItem (HEADER_ROW_NAME, COLUMN_HEADER_LABEL,
new QStandardItem (tokenCurveName ()));
108 m_model->setItem (HEADER_ROW_FUNC_AREA, COLUMN_HEADER_LABEL,
new QStandardItem (tokenFunctionArea ()));
109 m_model->setItem (HEADER_ROW_POLY_AREA, COLUMN_HEADER_LABEL,
new QStandardItem (tokenPolygonArea ()));
110 m_model->setItem (HEADER_ROW_COLUMN_NAMES, COLUMN_BODY_X,
new QStandardItem (tokenX ()));
111 m_model->setItem (HEADER_ROW_COLUMN_NAMES, COLUMN_BODY_Y,
new QStandardItem (tokenY ()));
112 m_model->setItem (HEADER_ROW_COLUMN_NAMES, COLUMN_BODY_INDEX,
new QStandardItem (tokenIndex ()));
113 m_model->setItem (HEADER_ROW_COLUMN_NAMES, COLUMN_BODY_DISTANCE_GRAPH_FORWARD,
new QStandardItem (tokenDistanceGraph ()));
114 m_model->setItem (HEADER_ROW_COLUMN_NAMES, COLUMN_BODY_DISTANCE_PERCENT_FORWARD,
new QStandardItem (tokenDistancePercent ()));
115 m_model->setItem (HEADER_ROW_COLUMN_NAMES, COLUMN_BODY_DISTANCE_GRAPH_BACKWARD,
new QStandardItem (tokenDistanceGraph ()));
116 m_model->setItem (HEADER_ROW_COLUMN_NAMES, COLUMN_BODY_DISTANCE_PERCENT_BACKWARD,
new QStandardItem (tokenDistancePercent ()));
119 void GeometryWindow::loadStrategies ()
121 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryWindow::loadStrategies";
124 void GeometryWindow::resizeTable (
int rowCount)
126 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryWindow::resizeTable";
130 m_model->setRowCount (rowCount);
131 m_model->setColumnCount (NUM_BODY_COLUMNS);
145 QString GeometryWindow::tokenCurveName ()
const 147 return QString (
"%1:").arg (QObject::tr (
"CurveName"));
150 QString GeometryWindow::tokenDistanceGraph ()
const 152 return QObject::tr (
"Distance");
155 QString GeometryWindow::tokenDistancePercent ()
const 157 return QObject::tr (
"Percent");
160 QString GeometryWindow::tokenFunctionArea ()
const 162 return QString (
"%1:").arg (QObject::tr (
"FunctionArea"));
165 QString GeometryWindow::tokenIndex ()
const 167 return QObject::tr (
"Index");
170 QString GeometryWindow::tokenPolygonArea ()
const 172 return QString (
"%1:").arg (QObject::tr (
"PolygonArea"));
175 QString GeometryWindow::tokenX ()
const 177 return QObject::tr (
"X");
180 QString GeometryWindow::tokenY ()
const 182 return QObject::tr (
"Y");
185 void GeometryWindow::unselectAll ()
187 QItemSelectionModel *selectionModel = m_view->selectionModel ();
189 selectionModel->clearSelection ();
194 const QString &curveSelected,
197 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryWindow::update";
199 const int NUM_LEGEND_ROWS_UNSPANNED = 2;
209 ENGAUGE_CHECK_PTR (curve);
211 const Points points = curve->
points();
213 QString funcArea, polyArea;
214 QVector<QString> x, y, distanceGraphForward, distancePercentForward, distanceGraphBackward, distancePercentBackward;
215 QVector<bool> isPotentialExportAmbiguity;
228 isPotentialExportAmbiguity,
229 distanceGraphForward,
230 distancePercentForward,
231 distanceGraphBackward,
232 distancePercentBackward);
235 bool wasAmbiguity = isPotentialExportAmbiguity.contains (
true);
238 m_view->clearSpans();
241 resizeTable (NUM_HEADER_ROWS + points.count() + (wasAmbiguity ? NUM_LEGEND_ROWS_UNSPANNED : 0));
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));
247 if (transformation.transformIsDefined()) {
251 int row = NUM_HEADER_ROWS;
252 for (
int index = 0; index < points.count(); row++, index++) {
254 const Point &point = points.at (index);
257 transformation.transformScreenToRawGraph (point.
posScreen (),
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()));
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.")));
284 m_view->setColumnHidden (COLUMN_BODY_POINT_IDENTIFIERS,
true);
289 return dynamic_cast<QTableView*> (m_view);
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
CurveConnectAs curveConnectAs() const
Get method for connect type.
void setCurrentPointIdentifier(const QString &pointIdentifier)
Set the point identifier to be highlighted. Value is empty for no highlighting.
virtual void closeEvent(QCloseEvent *event)
Catch close event so corresponding menu item in MainWindow can be updated accordingly.
virtual QTableView * view() const
QTableView-based class used by child class.
Dockable widget abstract base class.
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
void slotPointHoverEnter(QString)
Highlight the row for the specified point.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
virtual void update(const CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow, const QString &curveSelected, const Transformation &transformation)
Populate the table with the specified Curve.
const Points points() const
Return a shallow copy of the Points.
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.
QString selectionAsText(ExportDelimiter delimiter) const
Convert the selection into exportable text which is good for text editors.
QString identifier() const
Unique identifier for a specific Point.
void slotPointHoverLeave(QString)
Unhighlight the row for the specified point.
virtual void doCopy()
Copy the current selection to the clipboard.
void setDelimiter(ExportDelimiter delimiter)
Save output delimiter.
Model for DlgSettingsMainWindow.
LineStyle lineStyle() const
Get method for LineStyle.
GeometryWindow(MainWindow *mainWindow)
Single constructor. Parent is needed or else this widget cannot be redocked after being undocked.
void signalGeometryWindowClosed()
Signal that this QDockWidget was just closed.
static int columnBodyPointIdentifiers()
Hidden column that has the point identifiers.
Container for LineStyle and PointStyle for one Curve.
Table view class with support for both drag-and-drop and copy-and-paste.
Container for one set of digitized Points.
void setPotentialExportAmbiguity(const QVector< bool > &isPotentialExportAmbiguity)
Remember which rows could have ambiguities during export - these will be highlighted.
bool dragDropExport() const
Get method for drag and drop export.
DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
Model that adds row highlighting according to the currently select point identifier.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
virtual void clear()
Clear stale information.