16#include <QApplication>
18#include <QItemSelectionModel>
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);
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 (
""));
73 return COLUMN_BODY_POINT_IDENTIFIERS;
76void GeometryWindow::createWidgets (
MainWindow *mainWindow)
81 connect (m_view, SIGNAL (signalTableStatusChange ()),
82 mainWindow, SLOT (slotTableStatusChange ()));
91 QString text = m_model->selectionAsText (m_modelExport.delimiter());
93 if (!text.isEmpty ()) {
96 QApplication::clipboard ()->setText (text);
101void 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 ()));
119void GeometryWindow::loadStrategies ()
124void GeometryWindow::resizeTable (
int rowCount)
130 m_model->setRowCount (rowCount);
131 m_model->setColumnCount (NUM_BODY_COLUMNS);
137 m_model->setCurrentPointIdentifier (pointIdentifier);
142 m_model->setCurrentPointIdentifier (
"");
145QString GeometryWindow::tokenCurveName ()
const
147 return QString (
"%1:").arg (QObject::tr (
"CurveName"));
150QString GeometryWindow::tokenDistanceGraph ()
const
152 return QObject::tr (
"Distance");
155QString GeometryWindow::tokenDistancePercent ()
const
157 return QObject::tr (
"Percent");
160QString GeometryWindow::tokenFunctionArea ()
const
162 return QString (
"%1:").arg (QObject::tr (
"FunctionArea"));
165QString GeometryWindow::tokenIndex ()
const
167 return QObject::tr (
"Index");
170QString GeometryWindow::tokenPolygonArea ()
const
172 return QString (
"%1:").arg (QObject::tr (
"PolygonArea"));
175QString GeometryWindow::tokenX ()
const
177 return QObject::tr (
"X");
180QString GeometryWindow::tokenY ()
const
182 return QObject::tr (
"Y");
185void GeometryWindow::unselectAll ()
187 QItemSelectionModel *selectionModel = m_view->selectionModel ();
189 selectionModel->clearSelection ();
194 const QString &curveSelected,
199 const int NUM_LEGEND_ROWS_UNSPANNED = 2;
213 QString funcArea, polyArea;
214 QVector<QString> x, y, distanceGraphForward, distancePercentForward, distanceGraphBackward, distancePercentBackward;
215 QVector<bool> isPotentialExportAmbiguity;
218 m_geometryStrategyContext.calculateGeometry (points,
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));
249 m_model->setPotentialExportAmbiguity (isPotentialExportAmbiguity);
251 int row = NUM_HEADER_ROWS;
252 for (
int index = 0; index < points.count(); row++, index++) {
254 const Point &point = points.at (index);
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);
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.
log4cpp::Category * mainCat
Container for LineStyle and PointStyle for one Curve.
LineStyle lineStyle() const
Get method for LineStyle.
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
Container for one set of digitized Points.
const Points points() const
Return a shallow copy of the Points.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
Model that adds row highlighting according to the currently select point identifier.
static int columnBodyPointIdentifiers()
Hidden column that has the point identifiers.
GeometryWindow(MainWindow *mainWindow)
Single constructor. Parent is needed or else this widget cannot be redocked after being undocked.
virtual void update(const CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow, const QString &curveSelected, const Transformation &transformation)
Populate the table with the specified Curve.
virtual void closeEvent(QCloseEvent *event)
Catch close event so corresponding menu item in MainWindow can be updated accordingly.
void slotPointHoverEnter(QString)
Highlight the row for the specified point.
virtual QTableView * view() const
QTableView-based class used by child class.
void slotPointHoverLeave(QString)
Unhighlight the row for the specified point.
virtual void clear()
Clear stale information.
virtual void doCopy()
Copy the current selection to the clipboard.
virtual ~GeometryWindow()
void signalGeometryWindowClosed()
Signal that this QDockWidget was just closed.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Model for DlgSettingsMainWindow.
bool dragDropExport() const
Get method for drag and drop export.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
QString identifier() const
Unique identifier for a specific Point.
WindowAbstractBase(QWidget *parent)
Single constructor. Parent is needed or else this widget cannot be redocked after being undocked.
Table view class with support for both drag-and-drop and copy-and-paste.
#define LOG4CPP_INFO_S(logger)