Skip to content

Commit

Permalink
result of code review
Browse files Browse the repository at this point in the history
  • Loading branch information
gusohler committed Dec 27, 2023
1 parent 0171180 commit eec7b37
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 7 deletions.
37 changes: 37 additions & 0 deletions resources/icons/svg-default/icons.scad
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ icons = [
["vcr-control-pause"],
["vcr-control-step-forward"],
["vcr-control-end"],
["measure-dist"],
["measure-ang"]
];

icon(selected_icon) {
Expand Down Expand Up @@ -121,6 +123,8 @@ icon(selected_icon) {
vcr_control_pause();
vcr_control_step_forward();
vcr_control_end();
measure_dist();
measure_ang();
}

if (list_icons) {
Expand Down Expand Up @@ -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);
}
3 changes: 1 addition & 2 deletions src/core/Selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@

enum { SELECTION_POINT, SELECTION_LINE};

class SelectedObject {
public:
struct SelectedObject {
int type;
Vector3d p1;
Vector3d p2;
Expand Down
1 change: 0 additions & 1 deletion src/glview/cgal/CGALRenderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ std::vector<SelectedObject> 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;
Expand Down
4 changes: 3 additions & 1 deletion src/gui/MainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/Measurement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
*/

#include <Measurement.h>
#include "Measurement.h"

Measurement::Measurement()
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Measurement.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#pragma once

#include <QGLView.h>
#include "QGLView.h"

enum { MEASURE_IDLE, MEASURE_DIST1, MEASURE_DIST2, MEASURE_ANG1, MEASURE_ANG2, MEASURE_ANG3 };

Expand Down
2 changes: 1 addition & 1 deletion src/gui/QGLView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#endif

#include "qt-obsolete.h"
#include <Measurement.h>
#include "Measurement.h"

QGLView::QGLView(QWidget *parent) : QOpenGLWidget(parent)
{
Expand Down
6 changes: 6 additions & 0 deletions src/gui/ScintillaEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,12 @@ QString ScintillaEditor::selectedText()

bool ScintillaEditor::eventFilter(QObject *obj, QEvent *e)
{
if (e->type() == QEvent::KeyPress) {
auto keyEvent = static_cast<QKeyEvent *>(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;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ScintillaEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit eec7b37

Please sign in to comment.