PartDesign/TaskLoftParameters: Added UpdateView checkbox +cleanup

This commit is contained in:
Alexander Golubev 2015-09-11 05:53:22 +03:00 committed by Stefan Tröger
parent efef23d8e2
commit 36fbf73011
3 changed files with 43 additions and 73 deletions

View File

@ -71,6 +71,8 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool newObj, Q
this, SLOT(onRuled(bool)));
connect(ui->checkBoxClosed, SIGNAL(toggled(bool)),
this, SLOT(onClosed(bool)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
this->groupLayout()->addWidget(proxy);
@ -78,12 +80,10 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool newObj, Q
for(QWidget* child : proxy->findChildren<QWidget*>())
child->blockSignals(true);
// activate and de-activate dialog elements as appropriate
for(QWidget* child : proxy->findChildren<QWidget*>())
child->blockSignals(false);
updateUI(0);
}
@ -106,12 +106,12 @@ void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
else if (selectionMode == refRemove) {
QString objn = QString::fromStdString(msg.pObjectName);
if(!objn.isEmpty())
removeFromListWidget(ui->listWidgetReferences, objn);
removeFromListWidget(ui->listWidgetReferences, objn);
}
clearButtons();
//static_cast<ViewProviderLoft*>(vp)->highlightReferences(false, true);
recomputeFeature();
}
}
clearButtons();
exitSelectionMode();
}
@ -120,7 +120,6 @@ void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) const {
if ((msg.Type == Gui::SelectionChanges::AddSelection) && (
(selectionMode == refAdd) || (selectionMode == refRemove))) {
@ -128,14 +127,14 @@ bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) con
return false;
// not allowed to reference ourself
const char* fname = vp->getObject()->getNameInDocument();
const char* fname = vp->getObject()->getNameInDocument();
if (strcmp(msg.pObjectName, fname) == 0)
return false;
//every selection needs to be a profile in itself, hence currently only full objects are
//every selection needs to be a profile in itself, hence currently only full objects are
//supported, not individual edges of a part
//change the references
//change the references
std::vector<App::DocumentObject*> refs = static_cast<PartDesign::Loft*>(vp->getObject())->Sections.getValues();
App::DocumentObject* obj = vp->getObject()->getDocument()->getObject(msg.pObjectName);
std::vector<App::DocumentObject*>::iterator f = std::find(refs.begin(), refs.end(), obj);
@ -150,7 +149,7 @@ bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) con
refs.erase(f);
else
return false;
}
}
static_cast<PartDesign::Loft*>(vp->getObject())->Sections.setValues(refs);
return true;
@ -239,7 +238,7 @@ void TaskLoftParameters::onRuled(bool val) {
void TaskLoftParameters::onRefButtonAdd(bool checked) {
if (checked) {
Gui::Selection().clearSelection();
Gui::Selection().clearSelection();
selectionMode = refAdd;
//static_cast<ViewProviderLoft*>(vp)->highlightReferences(true, true);
}
@ -248,13 +247,14 @@ void TaskLoftParameters::onRefButtonAdd(bool checked) {
void TaskLoftParameters::onRefButtonRemvove(bool checked) {
if (checked) {
Gui::Selection().clearSelection();
Gui::Selection().clearSelection();
selectionMode = refRemove;
//static_cast<ViewProviderLoft*>(vp)->highlightReferences(true, true);
}
}
//**************************************************************************
//**************************************************************************
// TaskDialog
@ -271,60 +271,17 @@ TaskDlgLoftParameters::TaskDlgLoftParameters(ViewProviderLoft *LoftView,bool new
TaskDlgLoftParameters::~TaskDlgLoftParameters()
{
}
bool TaskDlgLoftParameters::accept()
{
// TODO Fill this with commands (2015-09-11, Fat-Zer)
return TaskDlgSketchBasedParameters::accept ();
}
//==== calls from the TaskView ===============================================================
bool TaskDlgLoftParameters::accept()
{
std::string name = vp->getObject()->getNameInDocument();
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!vp->getObject()->isValid())
throw Base::Exception(vp->getObject()->getStatusString());
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromUtf8(e.what()));
return false;
}
return true;
}
//bool TaskDlgLoftParameters::reject()
//{
// // get the support and Sketch
// PartDesign::Loft* pcLoft = static_cast<PartDesign::Loft*>(LoftView->getObject());
// Sketcher::SketchObject *pcSketch = 0;
// App::DocumentObject *pcSupport = 0;
// if (pcLoft->Sketch.getValue()) {
// pcSketch = static_cast<Sketcher::SketchObject*>(pcLoft->Sketch.getValue());
// pcSupport = pcSketch->Support.getValue();
// }
//
// // roll back the done things
// Gui::Command::abortCommand();
// Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
//
// // if abort command deleted the object the support is visible again
// if (!Gui::Application::Instance->getViewProvider(pcLoft)) {
// if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
// Gui::Application::Instance->getViewProvider(pcSketch)->show();
// if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
// Gui::Application::Instance->getViewProvider(pcSupport)->show();
// }
//
// //Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
// //Gui::Command::commitCommand();
//
// return true;
//}
#include "moc_TaskLoftParameters.cpp"

View File

@ -42,8 +42,7 @@ namespace Gui {
class ViewProvider;
}
namespace PartDesignGui {
namespace PartDesignGui {
class TaskLoftParameters : public TaskSketchBasedParameters
@ -59,7 +58,7 @@ private Q_SLOTS:
void onRefButtonRemvove(bool);
void onClosed(bool);
void onRuled(bool);
protected:
void changeEvent(QEvent *e);
@ -74,7 +73,7 @@ private:
private:
QWidget* proxy;
Ui_TaskLoftParameters* ui;
enum selectionModes { none, refAdd, refRemove };
selectionModes selectionMode = none;
};
@ -91,11 +90,8 @@ public:
ViewProviderLoft* getLoftView() const
{ return static_cast<ViewProviderLoft*>(vp); }
public:
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
/// is called by the framework if the dialog is rejected (Cancel)
protected:
TaskLoftParameters *parameter;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>305</height>
<width>262</width>
<height>270</height>
</rect>
</property>
<property name="windowTitle">
@ -74,6 +74,23 @@
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxUpdateView">
<property name="text">
<string>Update view</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>