##// END OF EJS Templates
Refac + clang-format...
jeandet -
r1365:19075a214d07
parent child
Show More
@@ -2,7 +2,7
2 # See http://clang.llvm.org/docs/ClangFormatStyleOptions.html for a definition
2 # See http://clang.llvm.org/docs/ClangFormatStyleOptions.html for a definition
3 # of the options
3 # of the options
4 Language: Cpp
4 Language: Cpp
5 BasedOnStyle: LLVM
5 BasedOnStyle: WebKit
6
6
7 # Line length
7 # Line length
8 ColumnLimit: 100
8 ColumnLimit: 100
@@ -12,8 +12,7 IndentWidth: 4
12 AccessModifierOffset: -4 # -IndentWidth
12 AccessModifierOffset: -4 # -IndentWidth
13 ConstructorInitializerIndentWidth: 8 # 2 * IndentWidth
13 ConstructorInitializerIndentWidth: 8 # 2 * IndentWidth
14
14
15 # Break only before function braces
15 BreakBeforeBraces: Allman
16 BreakBeforeBraces: Stroustrup
17
16
18 AllowShortFunctionsOnASingleLine: Inline
17 AllowShortFunctionsOnASingleLine: Inline
19 AlwaysBreakTemplateDeclarations: true
18 AlwaysBreakTemplateDeclarations: true
@@ -22,5 +21,6 BreakBeforeBinaryOperators: true
22 ConstructorInitializerAllOnOneLineOrOnePerLine: true
21 ConstructorInitializerAllOnOneLineOrOnePerLine: true
23 IndentCaseLabels: true
22 IndentCaseLabels: true
24 MaxEmptyLinesToKeep: 2
23 MaxEmptyLinesToKeep: 2
25 Standard: Cpp03
24 Standard: Cpp11
25 UseTab: Never
26
26
@@ -31,7 +31,7 endif()
31 if(NOT CMAKE_BUILD_TYPE)
31 if(NOT CMAKE_BUILD_TYPE)
32 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
32 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
33 endif()
33 endif()
34 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
34 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3")
35
35
36 find_package(Qt5 COMPONENTS Core Widgets Network PrintSupport Svg Test REQUIRED)
36 find_package(Qt5 COMPONENTS Core Widgets Network PrintSupport Svg Test REQUIRED)
37
37
@@ -169,9 +169,15 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
169 }
169 }
170 }
170 }
171
171
172 void startDrawingZone(const QPoint &pos, VisualizationGraphWidget *graph)
172 void selectZone(const QPoint &pos)
173 {
173 {
174 endDrawingZone(graph);
174 auto zoneAtPos = selectionZoneAt(pos);
175 setSelectionZonesEditionEnabled(sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones);
176 }
177
178 void startDrawingZone(const QPoint &pos)
179 {
180 endDrawingZone();
175
181
176 auto axisPos = posToAxisPos(pos);
182 auto axisPos = posToAxisPos(pos);
177
183
@@ -180,7 +186,7 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
180 m_DrawingZone->setEditionEnabled(false);
186 m_DrawingZone->setEditionEnabled(false);
181 }
187 }
182
188
183 void endDrawingZone(VisualizationGraphWidget *graph)
189 void endDrawingZone()
184 {
190 {
185 if (m_DrawingZone) {
191 if (m_DrawingZone) {
186 auto drawingZoneRange = m_DrawingZone->range();
192 auto drawingZoneRange = m_DrawingZone->range();
@@ -189,14 +195,24 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
189 addSelectionZone(m_DrawingZone);
195 addSelectionZone(m_DrawingZone);
190 }
196 }
191 else {
197 else {
192 graph->plot().removeItem(m_DrawingZone); // the item is deleted by QCustomPlot
198 m_plot->removeItem(m_DrawingZone);
193 }
199 }
194
200
195 graph->plot().replot(QCustomPlot::rpQueuedReplot);
201 m_plot->replot(QCustomPlot::rpQueuedReplot);
196 m_DrawingZone = nullptr;
202 m_DrawingZone = nullptr;
197 }
203 }
198 }
204 }
199
205
206 void moveSelectionZone(const QPoint& destination)
207 {
208 /*
209 * I give up on this for now
210 * @TODO implement this, the difficulty is that selection zones have their own
211 * event handling code which seems to rely on QCP GUI event handling propagation
212 * which was a realy bad design choice.
213 */
214 }
215
200 void setSelectionZonesEditionEnabled(bool value)
216 void setSelectionZonesEditionEnabled(bool value)
201 {
217 {
202 for (auto s : m_SelectionZones) {
218 for (auto s : m_SelectionZones) {
@@ -783,13 +799,22 void VisualizationGraphWidget::mouseMoveEvent(QMouseEvent *event)
783 }
799 }
784 else if (event->buttons() == Qt::LeftButton)
800 else if (event->buttons() == Qt::LeftButton)
785 {
801 {
786 impl->moveGraph(event->pos());
802 switch (sqpApp->plotsInteractionMode())
803 {
804 case SqpApplication::PlotsInteractionMode::None:
805 impl->moveGraph(event->pos());
806 break;
807 case SqpApplication::PlotsInteractionMode::SelectionZones:
808
809 break;
810 default:
811 break;
812 }
787 }
813 }
788 else
814 else
789 {
815 {
790 impl->m_RenderingDelegate->updateTooltip(event);
816 impl->m_RenderingDelegate->updateTooltip(event);
791 }
817 }
792 event->accept();
793 QWidget::mouseMoveEvent(event);
818 QWidget::mouseMoveEvent(event);
794 }
819 }
795
820
@@ -801,7 +826,7 void VisualizationGraphWidget::mouseReleaseEvent(QMouseEvent *event)
801 }
826 }
802 else if(impl->isDrawingZoneRect())
827 else if(impl->isDrawingZoneRect())
803 {
828 {
804 impl->endDrawingZone(this);
829 impl->endDrawingZone();
805 }
830 }
806 else
831 else
807 {
832 {
@@ -812,36 +837,44 void VisualizationGraphWidget::mouseReleaseEvent(QMouseEvent *event)
812
837
813 void VisualizationGraphWidget::mousePressEvent(QMouseEvent *event)
838 void VisualizationGraphWidget::mousePressEvent(QMouseEvent *event)
814 {
839 {
815 if (event->button() == Qt::LeftButton) {
840 if (event->button()==Qt::RightButton)
816 if (event->modifiers() == Qt::ControlModifier) {
841 {
817 }
842 onGraphMenuRequested(event->pos());
818 else if (event->modifiers() == Qt::AltModifier) {
843 }
819
844 else
820 }
845 {
821 else
846 auto selectedZone = impl->selectionZoneAt(event->pos());
847 switch (sqpApp->plotsInteractionMode())
822 {
848 {
823 switch (sqpApp->plotsInteractionMode())
849 case SqpApplication::PlotsInteractionMode::DragAndDrop :
850 break;
851 case SqpApplication::PlotsInteractionMode::SelectionZones :
852 impl->setSelectionZonesEditionEnabled(true);
853 if ((event->modifiers() == Qt::ControlModifier) && (selectedZone != nullptr))
824 {
854 {
825 case SqpApplication::PlotsInteractionMode::DragAndDrop :
855 selectedZone->setAssociatedEditedZones(parentVisualizationWidget()->selectionZoneManager().selectedItems());
826 break;
856 }
827 case SqpApplication::PlotsInteractionMode::SelectionZones :
857 else
828 if (!impl->selectionZoneAt(event->pos())) {
858 {
829 impl->startDrawingZone(event->pos(), this);
859 if (!selectedZone)
860 {
861 parentVisualizationWidget()->selectionZoneManager().clearSelection();
862 impl->startDrawingZone(event->pos());
863 }
864 else
865 {
866 parentVisualizationWidget()->selectionZoneManager().select({ selectedZone });
830 }
867 }
831 break;
832 case SqpApplication::PlotsInteractionMode::ZoomBox :
833 impl->startDrawingRect(event->pos());
834 break;
835 default:
836 setCursor(Qt::ClosedHandCursor);
837 impl->updateMousePosition(event->pos());
838 }
868 }
869 break;
870 case SqpApplication::PlotsInteractionMode::ZoomBox :
871 impl->startDrawingRect(event->pos());
872 break;
873 default:
874 setCursor(Qt::ClosedHandCursor);
875 impl->updateMousePosition(event->pos());
839 }
876 }
840 }
877 }
841 else if (event->button()==Qt::RightButton)
842 {
843 onGraphMenuRequested(event->pos());
844 }
845 QWidget::mousePressEvent(event);
878 QWidget::mousePressEvent(event);
846 }
879 }
847
880
@@ -1128,7 +1161,7 void VisualizationGraphWidget::onMousePress(QMouseEvent *event) noexcept
1128 // Starts a new selection zone
1161 // Starts a new selection zone
1129 auto zoneAtPos = impl->selectionZoneAt(event->pos());
1162 auto zoneAtPos = impl->selectionZoneAt(event->pos());
1130 if (!zoneAtPos) {
1163 if (!zoneAtPos) {
1131 impl->startDrawingZone(event->pos(), this);
1164 impl->startDrawingZone(event->pos());
1132 }
1165 }
1133 }
1166 }
1134 }
1167 }
@@ -1191,7 +1224,7 void VisualizationGraphWidget::onMouseRelease(QMouseEvent *event) noexcept
1191 }
1224 }
1192 }
1225 }
1193
1226
1194 impl->endDrawingZone(this);
1227 impl->endDrawingZone();
1195
1228
1196 // Selection / Deselection
1229 // Selection / Deselection
1197 auto isSelectionZoneMode
1230 auto isSelectionZoneMode
@@ -29,7 +29,6 ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableCo
29 while (!isReady(var))\
29 while (!isReady(var))\
30 QCoreApplication::processEvents();\
30 QCoreApplication::processEvents();\
31 w.addVariable(var, range);\
31 w.addVariable(var, range);\
32 GET_CHILD_WIDGET_FOR_GUI_TESTS(w, plot, QCustomPlot, "widget");\
33 auto cent = center(&w);
32 auto cent = center(&w);
34
33
35
34
General Comments 0
You need to be logged in to leave comments. Login now