TaskFilletParameters.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 #endif
00028
00029 #include "ui_TaskFilletParameters.h"
00030 #include "TaskFilletParameters.h"
00031 #include <App/Application.h>
00032 #include <App/Document.h>
00033 #include <Gui/Application.h>
00034 #include <Gui/Document.h>
00035 #include <Gui/BitmapFactory.h>
00036 #include <Gui/ViewProvider.h>
00037 #include <Gui/WaitCursor.h>
00038 #include <Base/Console.h>
00039 #include <Gui/Selection.h>
00040 #include <Gui/Command.h>
00041 #include <Mod/PartDesign/App/FeatureFillet.h>
00042 #include <Mod/Sketcher/App/SketchObject.h>
00043
00044
00045 using namespace PartDesignGui;
00046 using namespace Gui;
00047
00048
00049
00050 TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidget *parent)
00051 : TaskBox(Gui::BitmapFactory().pixmap("Part_Fillet"),tr("Fillet parameters"),true, parent),FilletView(FilletView)
00052 {
00053
00054 proxy = new QWidget(this);
00055 ui = new Ui_TaskFilletParameters();
00056 ui->setupUi(proxy);
00057 QMetaObject::connectSlotsByName(this);
00058
00059 connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
00060 this, SLOT(onLengthChanged(double)));
00061
00062 this->groupLayout()->addWidget(proxy);
00063
00064 PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
00065 double r = pcFillet->Radius.getValue();
00066
00067 ui->doubleSpinBox->setMaximum(INT_MAX);
00068 ui->doubleSpinBox->setValue(r);
00069 ui->doubleSpinBox->selectAll();
00070
00071
00072 setFocus ();
00073 }
00074
00075 void TaskFilletParameters::onLengthChanged(double len)
00076 {
00077 PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
00078 pcFillet->Radius.setValue((float)len);
00079 pcFillet->getDocument()->recomputeFeature(pcFillet);
00080 }
00081
00082 double TaskFilletParameters::getLength(void) const
00083 {
00084 return ui->doubleSpinBox->value();
00085 }
00086
00087
00088 TaskFilletParameters::~TaskFilletParameters()
00089 {
00090 delete ui;
00091 }
00092
00093 void TaskFilletParameters::changeEvent(QEvent *e)
00094 {
00095 TaskBox::changeEvent(e);
00096 if (e->type() == QEvent::LanguageChange) {
00097 ui->retranslateUi(proxy);
00098 }
00099 }
00100
00101
00102
00103
00104
00105
00106 TaskDlgFilletParameters::TaskDlgFilletParameters(ViewProviderFillet *FilletView)
00107 : TaskDialog(),FilletView(FilletView)
00108 {
00109 assert(FilletView);
00110 parameter = new TaskFilletParameters(FilletView);
00111
00112 Content.push_back(parameter);
00113 }
00114
00115 TaskDlgFilletParameters::~TaskDlgFilletParameters()
00116 {
00117
00118 }
00119
00120
00121
00122
00123 void TaskDlgFilletParameters::open()
00124 {
00125
00126 }
00127
00128 void TaskDlgFilletParameters::clicked(int)
00129 {
00130
00131 }
00132
00133 bool TaskDlgFilletParameters::accept()
00134 {
00135 std::string name = FilletView->getObject()->getNameInDocument();
00136
00137
00138 Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Radius = %f",name.c_str(),parameter->getLength());
00139 Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
00140 Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
00141 Gui::Command::commitCommand();
00142
00143 return true;
00144 }
00145
00146 bool TaskDlgFilletParameters::reject()
00147 {
00148
00149 PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
00150 App::DocumentObject *pcSupport;
00151 pcSupport = pcFillet->Base.getValue();
00152
00153
00154 Gui::Command::abortCommand();
00155 Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
00156
00157
00158 if (!Gui::Application::Instance->getViewProvider(pcFillet)) {
00159 if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
00160 Gui::Application::Instance->getViewProvider(pcSupport)->show();
00161 }
00162
00163 return true;
00164 }
00165
00166
00167
00168 #include "moc_TaskFilletParameters.cpp"