diff --git a/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp b/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp index d9e7872dd..22f7576bc 100644 --- a/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp @@ -23,9 +23,11 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include #endif +#include #include #include @@ -34,9 +36,16 @@ using namespace SketcherGui; -SketchOrientationDialog::SketchOrientationDialog(void) +SketchOrientationDialog::SketchOrientationDialog(void) + : QDialog(Gui::getMainWindow()), ui(new Ui_SketchOrientationDialog) { + ui->setupUi(this); + onPreview(); + connect(ui->Reverse_checkBox, SIGNAL(clicked(bool)), this, SLOT(onPreview())); + connect(ui->XY_radioButton , SIGNAL(clicked(bool)), this, SLOT(onPreview())); + connect(ui->XZ_radioButton , SIGNAL(clicked(bool)), this, SLOT(onPreview())); + connect(ui->YZ_radioButton , SIGNAL(clicked(bool)), this, SLOT(onPreview())); } SketchOrientationDialog::~SketchOrientationDialog() @@ -44,51 +53,70 @@ SketchOrientationDialog::~SketchOrientationDialog() } -int SketchOrientationDialog::exec() +void SketchOrientationDialog::accept() { - //Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView(); - //Gui::View3DInventorViewer *viewer = static_cast(mdi)->getViewer(); - - QDialog dlg(Gui::getMainWindow()); - - Ui::SketchOrientationDialog ui_SketchOrientationDialog; - ui_SketchOrientationDialog.setupUi(&dlg); - - int res; - if (res=dlg.exec()) { - double offset = ui_SketchOrientationDialog.Offset_doubleSpinBox->value(); - bool reverse = ui_SketchOrientationDialog.Reverse_checkBox->isChecked(); - if (ui_SketchOrientationDialog.XY_radioButton->isChecked()) { - if (reverse) { - Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation(-1.0,0.0,0.0,0.0)); - DirType = 1; - } - else { - Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation()); - DirType = 0; - } + double offset = ui->Offset_doubleSpinBox->value(); + bool reverse = ui->Reverse_checkBox->isChecked(); + if (ui->XY_radioButton->isChecked()) { + if (reverse) { + Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation(-1.0,0.0,0.0,0.0)); + DirType = 1; } - else if (ui_SketchOrientationDialog.XZ_radioButton->isChecked()) { - if (reverse) { - Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0),M_PI)); - DirType = 3; - } - else { - Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(-1,0,0),1.5*M_PI)); - DirType = 2; - } + else { + Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation()); + DirType = 0; } - else if (ui_SketchOrientationDialog.YZ_radioButton->isChecked()) { - if (reverse) { - Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(-0.5,0.5,0.5,-0.5)); - DirType = 5; - } - else { - Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(0.5,0.5,0.5,0.5)); - DirType = 4; - } + } + else if (ui->XZ_radioButton->isChecked()) { + if (reverse) { + Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0),M_PI)); + DirType = 3; + } + else { + Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(-1,0,0),1.5*M_PI)); + DirType = 2; + } + } + else if (ui->YZ_radioButton->isChecked()) { + if (reverse) { + Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(-0.5,0.5,0.5,-0.5)); + DirType = 5; + } + else { + Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(0.5,0.5,0.5,0.5)); + DirType = 4; } } - return res; + QDialog::accept(); } + +void SketchOrientationDialog::onPreview() +{ + std::string icon; + bool reverse = ui->Reverse_checkBox->isChecked(); + if (ui->XY_radioButton->isChecked()) { + if (reverse) + icon = "view-bottom"; + else + icon = "view-top"; + } + else if (ui->XZ_radioButton->isChecked()) { + if (reverse) + icon = "view-rear"; + else + icon = "view-front"; + } + else if (ui->YZ_radioButton->isChecked()) { + if (reverse) + icon = "view-left"; + else + icon = "view-right"; + } + + ui->previewLabel->setPixmap( + Gui::BitmapFactory().pixmapFromSvg(icon.c_str(), + ui->previewLabel->size())); +} + +#include "moc_SketchOrientationDialog.cpp" diff --git a/src/Mod/Sketcher/Gui/SketchOrientationDialog.h b/src/Mod/Sketcher/Gui/SketchOrientationDialog.h index 0dd3cf070..4865ee7bd 100644 --- a/src/Mod/Sketcher/Gui/SketchOrientationDialog.h +++ b/src/Mod/Sketcher/Gui/SketchOrientationDialog.h @@ -24,20 +24,31 @@ #define SKETCHERGUI_SketchOrientationDialog_H #include +#include namespace SketcherGui { -class SketchOrientationDialog { +class Ui_SketchOrientationDialog; +class SketchOrientationDialog : public QDialog +{ + Q_OBJECT + public: SketchOrientationDialog(void); ~SketchOrientationDialog(); - int exec(); - Base::Placement Pos; int DirType; - + + void accept(); + +protected Q_SLOTS: + void onPreview(); + +private: + Ui_SketchOrientationDialog* ui; }; } + #endif // SKETCHERGUI_SketchOrientationDialog_H diff --git a/src/Mod/Sketcher/Gui/SketchOrientationDialog.ui b/src/Mod/Sketcher/Gui/SketchOrientationDialog.ui index d8b55e229..dd0e5f69c 100644 --- a/src/Mod/Sketcher/Gui/SketchOrientationDialog.ui +++ b/src/Mod/Sketcher/Gui/SketchOrientationDialog.ui @@ -1,7 +1,7 @@ - SketchOrientationDialog - + SketcherGui::SketchOrientationDialog + 0 @@ -13,8 +13,8 @@ Choose orientation - - + + Sketch orientation @@ -47,14 +47,33 @@ - + + + + + 48 + 48 + + + + + 48 + 48 + + + + Preview + + + + Reverse direction - + @@ -81,7 +100,7 @@ - + Qt::Horizontal @@ -98,7 +117,7 @@ buttonBox accepted() - SketchOrientationDialog + SketcherGui::SketchOrientationDialog accept() @@ -114,7 +133,7 @@ buttonBox rejected() - SketchOrientationDialog + SketcherGui::SketchOrientationDialog reject()