This patch adds the ability to create cursors to measure values in the curves (x, y)
TODO:
- icon for the cursor action
- when clicking on the selection tool, the cursor disappear. Don't understand why
This patch adds the ability to create cursors to measure values in the curves (x, y)
TODO:
Lint Skipped |
Unit Tests Skipped |
The class name TreeModel sounds very generic but this model will most probably only used for cursors only. Can we call it CursorTreeModel similar to how have AspectTreeModel already?
The are several code style glitches. Please execute astyle with the options in admin/README.astyle.
src/backend/core/AbstractAspect.cpp | ||
---|---|---|
339 ↗ | (On Diff #59226) | remove empty line. |
src/backend/core/column/ColumnPrivate.cpp | ||
1289 ↗ | (On Diff #59226) | std::isnan(value) |
1299 ↗ | (On Diff #59226) | std::isnan(value) |
1301 ↗ | (On Diff #59226) | small typo - leave, not leaf. |
src/backend/worksheet/TreeModel.cpp | ||
36 ↗ | (On Diff #59226) | use constructor member initializer list. |
src/backend/worksheet/TreeModel.h | ||
63 ↗ | (On Diff #59226) | TreeItem* parentItem{nullptr}; |
74 ↗ | (On Diff #59226) | TreeModel(const QStringList& headers, QObject* parent = nullptr); |
106 ↗ | (On Diff #59226) | TreeItem* rootItem{nullptr}; |
src/backend/worksheet/Worksheet.cpp | ||
427 ↗ | (On Diff #59226) | remove empty line. |
429 ↗ | (On Diff #59226) | no brackets for one-liners. |
976 ↗ | (On Diff #59226) | In curveDataChanged() and in the following functions there is a lot of logic handling the tree model. Can me move this code into TreeModel and have in Worksheet only some abstract interface of the model hiding the technical details? |
1226 ↗ | (On Diff #59226) | add i18n for "Plot/Curve". |
src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp | ||
250 ↗ | (On Diff #59226) | add spaces between the operators here. |
src/backend/worksheet/plots/cartesian/CartesianPlot.cpp | ||
1069 ↗ | (On Diff #59226) | do we really need to retransform the scale if we set the pen for the cursor? |
1359 ↗ | (On Diff #59226) | "signal" is not the terminology used in the code. Let's stick to "curve". |
3050 ↗ | (On Diff #59226) | use WRITE_QPEN macro. |
src/commonfrontend/ProjectExplorer.cpp | ||
629 ↗ | (On Diff #59226) | use directly selectedAspects << static_cast<AbstractAspect*>(index.internalPointer());, no need for an extra variable and this assignment in the loop. |
src/kdefrontend/MainWin.cpp | ||
179 ↗ | (On Diff #59226) | i18n("Cursor") |
190 ↗ | (On Diff #59226) | isn't this obsolete since you set the title in the constructor already? |
src/kdefrontend/dockwidgets/CartesianPlotDock.h | ||
181 ↗ | (On Diff #59226) | void plotCursorPenChanged(QPen); |
src/backend/worksheet/plots/cartesian/CartesianPlot.cpp | ||
---|---|---|
1069 ↗ | (On Diff #59226) | No, think update should do the same job |
src/backend/worksheet/TreeModel.cpp | ||
---|---|---|
149 ↗ | (On Diff #59226) | use range-based loop |
165 ↗ | (On Diff #59226) | indentation? |
src/backend/worksheet/Worksheet.cpp | ||
1334 ↗ | (On Diff #59226) | auto* sender = ... |
1356 ↗ | (On Diff #59226) | auto* plot = ... |
1480 ↗ | (On Diff #59226) | auto* |
1519 ↗ | (On Diff #59226) | auto* |
1563 ↗ | (On Diff #59226) | auto* |
src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp | ||
609 ↗ | (On Diff #59226) | define temp vars for pageRect.x() and pageRect.y() too? |
src/backend/worksheet/plots/cartesian/CartesianPlot.cpp | ||
2575 ↗ | (On Diff #59226) | same as |
2689 ↗ | (On Diff #59226) | translation? |
src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp | ||
---|---|---|
711 ↗ | (On Diff #59226) | use temp vars here too? |
src/backend/worksheet/plots/cartesian/CartesianPlot.cpp | ||
2641 ↗ | (On Diff #59226) | use spaces: } else { |
2661 ↗ | (On Diff #59226) | space after "if": if (...) |
2690 ↗ | (On Diff #59226) | maybe better: |
2804 ↗ | (On Diff #59226) | maybe better: |
2972 ↗ | (On Diff #59226) | same as |
src/backend/worksheet/plots/cartesian/XYCurve.cpp | ||
2314 ↗ | (On Diff #59226) | do you really want abs() defined as please check all places where abs() is used |
src/commonfrontend/worksheet/WorksheetView.cpp | ||
1816 ↗ | (On Diff #59226) | no brackets for one-liners |
src/kdefrontend/dockwidgets/CartesianPlotDock.cpp | ||
103 ↗ | (On Diff #59226) | This is Qt::PenStyle, right? |
src/kdefrontend/dockwidgets/XYCurveDock.cpp | ||
513 ↗ | (On Diff #62011) | space before { |
There are couple of easy-to-fix compiler warnings
/Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:738:31: warning: comparison of two values with different enumeration types ('Worksheet::CartesianPlotActionMode' and 'WorksheetView::CartesianPlotActionMode') [-Wenum-compare] if(cartesianPlotActionMode() == WorksheetView::ApplyActionToAll){ ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:752:31: warning: comparison of two values with different enumeration types ('Worksheet::CartesianPlotActionMode' and 'WorksheetView::CartesianPlotActionMode') [-Wenum-compare] if(cartesianPlotActionMode() == WorksheetView::ApplyActionToAll){ ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:766:31: warning: comparison of two values with different enumeration types ('Worksheet::CartesianPlotActionMode' and 'WorksheetView::CartesianPlotActionMode') [-Wenum-compare] if(cartesianPlotCursorMode() == WorksheetView::ApplyActionToAll){ ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:783:31: warning: comparison of two values with different enumeration types ('Worksheet::CartesianPlotActionMode' and 'WorksheetView::CartesianPlotActionMode') [-Wenum-compare] if(cartesianPlotActionMode() == WorksheetView::ApplyActionToAll){ ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:797:31: warning: comparison of two values with different enumeration types ('Worksheet::CartesianPlotActionMode' and 'WorksheetView::CartesianPlotActionMode') [-Wenum-compare] if(cartesianPlotActionMode() == WorksheetView::ApplyActionToAll){ ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:811:32: warning: comparison of two values with different enumeration types ('Worksheet::CartesianPlotActionMode' and 'WorksheetView::CartesianPlotActionMode') [-Wenum-compare] if (cartesianPlotCursorMode() == WorksheetView::ApplyActionToAll) { ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:843:31: warning: comparison of two values with different enumeration types ('Worksheet::CartesianPlotActionMode' and 'WorksheetView::CartesianPlotActionMode') [-Wenum-compare] if(cartesianPlotCursorMode() == WorksheetView::ApplyActionToAll){ ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:997:7: warning: unused variable 'curveCount' [-Wunused-variable] int curveCount = treeModel->rowCount(plotIndex); ^ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:1037:7: warning: unused variable 'curveCount' [-Wunused-variable] int curveCount = treeModel->rowCount(plotIndex); ^ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:1208:8: warning: unused variable 'rowCount' [-Wunused-variable] int rowCount = treeModel->rowCount(plotName); ^ /Users/d058339/Projekte/labplot/src/backend/worksheet/Worksheet.cpp:1209:9: warning: unused variable 'success' [-Wunused-variable] bool success = treeModel->insertRows(treeModel->rowCount(plotName), 1, plotName); /Users/d058339/Projekte/labplot/src/backend/worksheet/TreeModel.cpp:36:2: warning: field 'parentItem' will be initialized after field 'itemData' [-Wreorder] parentItem(parent), ^ /Users/d058339/Projekte/labplot/src/backend/worksheet/TreeModel.cpp:315:19: warning: code will never be executed [-Wunreachable-code] bool result = rootItem->setData(section, value); ^~~~~~~~ /Users/d058339/Projekte/labplot/src/backend/worksheet/TreeModel.cpp:312:60: warning: code will never be executed [-Wunreachable-code] if (role != Qt::EditRole || role != Qt::DisplayRole || orientation != Qt::Horizontal)
The new cursor dock needs to be cleared and hidden when we close the project or create a new one.
src/kdefrontend/dockwidgets/CartesianPlotDock.cpp | ||
---|---|---|
103 ↗ | (On Diff #59226) | Jop it is :)
Jep |