diff --git a/resources/icons/svg-default/icons.scad b/resources/icons/svg-default/icons.scad index 7f6e068184e..8a4465b858d 100644 --- a/resources/icons/svg-default/icons.scad +++ b/resources/icons/svg-default/icons.scad @@ -67,6 +67,8 @@ icons = [ ["vcr-control-pause"], ["vcr-control-step-forward"], ["vcr-control-end"], + ["measure-dist"], + ["measure-ang"] ]; icon(selected_icon) { @@ -121,6 +123,8 @@ icon(selected_icon) { vcr_control_pause(); vcr_control_step_forward(); vcr_control_end(); + measure_dist(); + measure_ang(); } if (list_icons) { @@ -733,3 +737,36 @@ module vcr_control_end(){ translate([x, 0]) square([thick, 0.4 * width], center = true); } } + +module measure_dist(){ + x = 0.75 * width /2; + a = width*0.2; + t = thin*0.1; + offset(rounding) + translate([width/2,height/2]){ + for(mirr=[1,0,0]) mirror([mirr,0,0]) { + translate([x, 0]) square([t, 0.8 * width], center = true); + polygon([[x-t,-15],[x-a-t,a-15],[x-a-t,-a-15]]); + } + translate([0,-15]) square([2*x, thin], center = true); + } + translate([25,50]) + resize([40, 40], true) + text("10", 40, font = export_font); + +} + +module measure_ang() { + x = 0.75 * width /2; + a = width*0.2; + offset(rounding) + translate([width/2,height/2]){ + for(mirr=[1,0,0]) mirror([mirr,0,0]) { + translate([0, -x]) rotate([0,0,45]) square([thin, 0.8 * width/sqrt(2)]); + } + } + translate([width*0.5,width*0.6]) scale(0.7) curved_arrow(); + translate([30,30]) + resize([40, 40], true) + text("45", 40, font = export_font); +} diff --git a/src/core/Selection.h b/src/core/Selection.h index 9721502445f..df554793bca 100644 --- a/src/core/Selection.h +++ b/src/core/Selection.h @@ -30,8 +30,7 @@ enum { SELECTION_POINT, SELECTION_LINE}; -class SelectedObject { - public: +struct SelectedObject { int type; Vector3d p1; Vector3d p2; diff --git a/src/glview/cgal/CGALRenderer.cc b/src/glview/cgal/CGALRenderer.cc index 897cec9b56a..0d5ec808bce 100644 --- a/src/glview/cgal/CGALRenderer.cc +++ b/src/glview/cgal/CGALRenderer.cc @@ -396,7 +396,6 @@ std::vector CGALRenderer::findModelObject(Vector3d near_pt, Vect } if(!isnan(dist_nearest)) { -// printf("Found one line\n"); SelectedObject obj; obj.type = SELECTION_LINE; obj.p1=pt1_nearest; diff --git a/src/gui/MainWindow.cc b/src/gui/MainWindow.cc index 2d303437a94..fde298e46d5 100644 --- a/src/gui/MainWindow.cc +++ b/src/gui/MainWindow.cc @@ -704,6 +704,7 @@ MainWindow::MainWindow(const QStringList& filenames) connect(this->animateDock, SIGNAL(topLevelChanged(bool)), this, SLOT(animateTopLevelChanged(bool))); connect(this->viewportControlDock, SIGNAL(topLevelChanged(bool)), this, SLOT(viewportControlTopLevelChanged(bool))); + connect(this->activeEditor, SIGNAL(escapePressed()), this, SLOT(measureFinished())); // display this window and check for OpenGL 2.0 (OpenCSG) support viewModeThrownTogether(); show(); @@ -2324,6 +2325,7 @@ void MainWindow::leftClick(QPoint mouse) { QString str = meas.statemachine(mouse); if(str.size() > 0) { + this->qglview->measure_state = MEASURE_IDLE; QMenu resultmenu(this); auto action = resultmenu.addAction(str); connect(action, SIGNAL(triggered()), this, SLOT(measureFinished())); @@ -2400,7 +2402,7 @@ void MainWindow::rightClick(QPoint mouse) action->setProperty("line", location.firstLine()); action->setProperty("column", location.firstColumn()); - connect(action, SIGNAL(triggered()), this, SLOT(measureFinished())); + connect(action, SIGNAL(triggered()), this, SLOT(setCursor())); } } diff --git a/src/gui/Measurement.cc b/src/gui/Measurement.cc index 3d285d324b0..8abc6936db3 100644 --- a/src/gui/Measurement.cc +++ b/src/gui/Measurement.cc @@ -24,7 +24,7 @@ * */ -#include +#include "Measurement.h" Measurement::Measurement() { diff --git a/src/gui/Measurement.h b/src/gui/Measurement.h index e3183b0d1a7..d30f5d9a975 100644 --- a/src/gui/Measurement.h +++ b/src/gui/Measurement.h @@ -1,7 +1,7 @@ #pragma once -#include +#include "QGLView.h" enum { MEASURE_IDLE, MEASURE_DIST1, MEASURE_DIST2, MEASURE_ANG1, MEASURE_ANG2, MEASURE_ANG3 }; diff --git a/src/gui/QGLView.cc b/src/gui/QGLView.cc index 27160a382c7..f0757cffc39 100644 --- a/src/gui/QGLView.cc +++ b/src/gui/QGLView.cc @@ -57,7 +57,7 @@ #endif #include "qt-obsolete.h" -#include +#include "Measurement.h" QGLView::QGLView(QWidget *parent) : QOpenGLWidget(parent) { diff --git a/src/gui/ScintillaEditor.cc b/src/gui/ScintillaEditor.cc index 741a299bf22..c20956a2e41 100644 --- a/src/gui/ScintillaEditor.cc +++ b/src/gui/ScintillaEditor.cc @@ -911,6 +911,12 @@ QString ScintillaEditor::selectedText() bool ScintillaEditor::eventFilter(QObject *obj, QEvent *e) { + if (e->type() == QEvent::KeyPress) { + auto keyEvent = static_cast(e); + if (keyEvent->key() == Qt::Key_Escape) { + emit escapePressed(); + } + } if (QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) || QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier)) { if (!this->indicatorsActive) { this->indicatorsActive = true; diff --git a/src/gui/ScintillaEditor.h b/src/gui/ScintillaEditor.h index b65909282aa..477c87bb1bf 100644 --- a/src/gui/ScintillaEditor.h +++ b/src/gui/ScintillaEditor.h @@ -146,6 +146,8 @@ private slots: void fireModificationChanged(); void onIndicatorClicked(int line, int col, Qt::KeyboardModifiers state); void onIndicatorReleased(int line, int col, Qt::KeyboardModifiers state); +signals: + void escapePressed(void); public: void public_applySettings();