TaskPocketParameters.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_TaskPocketParameters.h"
00030 #include "TaskPocketParameters.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/FeaturePocket.h>
00042 #include <Mod/Sketcher/App/SketchObject.h>
00043
00044
00045 using namespace PartDesignGui;
00046 using namespace Gui;
00047
00048
00049
00050 TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidget *parent)
00051 : TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Pocket"),tr("Pocket parameters"),true, parent),PocketView(PocketView)
00052 {
00053
00054 proxy = new QWidget(this);
00055 ui = new Ui_TaskPocketParameters();
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::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
00065 double l = pcPocket->Length.getValue();
00066
00067 ui->doubleSpinBox->setMaximum(INT_MAX);
00068 ui->doubleSpinBox->setValue(l);
00069 ui->doubleSpinBox->selectAll();
00070
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 setFocus ();
00083 }
00084
00085 void TaskPocketParameters::onLengthChanged(double len)
00086 {
00087 PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
00088 pcPocket->Length.setValue((float)len);
00089 pcPocket->getDocument()->recomputeFeature(pcPocket);
00090 }
00091
00092 double TaskPocketParameters::getLength(void) const
00093 {
00094 return ui->doubleSpinBox->value();
00095 }
00096
00097
00098 TaskPocketParameters::~TaskPocketParameters()
00099 {
00100 delete ui;
00101 }
00102
00103 void TaskPocketParameters::changeEvent(QEvent *e)
00104 {
00105 TaskBox::changeEvent(e);
00106 if (e->type() == QEvent::LanguageChange) {
00107 ui->retranslateUi(proxy);
00108 }
00109 }
00110
00111
00112
00113
00114
00115
00116 TaskDlgPocketParameters::TaskDlgPocketParameters(ViewProviderPocket *PocketView)
00117 : TaskDialog(),PocketView(PocketView)
00118 {
00119 assert(PocketView);
00120 parameter = new TaskPocketParameters(PocketView);
00121
00122 Content.push_back(parameter);
00123 }
00124
00125 TaskDlgPocketParameters::~TaskDlgPocketParameters()
00126 {
00127
00128 }
00129
00130
00131
00132
00133 void TaskDlgPocketParameters::open()
00134 {
00135
00136 }
00137
00138 void TaskDlgPocketParameters::clicked(int)
00139 {
00140
00141 }
00142
00143 bool TaskDlgPocketParameters::accept()
00144 {
00145 std::string name = PocketView->getObject()->getNameInDocument();
00146
00147
00148 Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),parameter->getLength());
00149 Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
00150 Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
00151 Gui::Command::commitCommand();
00152
00153 return true;
00154 }
00155
00156 bool TaskDlgPocketParameters::reject()
00157 {
00158
00159 PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
00160 Sketcher::SketchObject *pcSketch;
00161 App::DocumentObject *pcSupport;
00162 if (pcPocket->Sketch.getValue()) {
00163 pcSketch = static_cast<Sketcher::SketchObject*>(pcPocket->Sketch.getValue());
00164 pcSupport = pcSketch->Support.getValue();
00165 }
00166
00167
00168 Gui::Command::abortCommand();
00169 Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
00170
00171
00172 if (!Gui::Application::Instance->getViewProvider(pcPocket)) {
00173 if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
00174 Gui::Application::Instance->getViewProvider(pcSketch)->show();
00175 if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
00176 Gui::Application::Instance->getViewProvider(pcSupport)->show();
00177 }
00178
00179
00180
00181
00182 return true;
00183 }
00184
00185
00186
00187 #include "moc_TaskPocketParameters.cpp"