diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index dfee930f48..730b77394e 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -25,8 +25,9 @@ #ifndef _PreComp_ #endif -#include +#include #include +#include #include "Application.h" #include "CommandT.h" #include "DockWindowManager.h" @@ -116,6 +117,10 @@ void StdCmdRandomColor::activated(int iMsg) } }; + auto allowToChangeColor = [](const App::DocumentObject* obj) { + return (obj->isDerivedFrom() || obj->isDerivedFrom()); + }; + // get the complete selection std::vector sel = Selection().getCompleteSelection(); @@ -125,10 +130,12 @@ void StdCmdRandomColor::activated(int iMsg) setRandomColor(view); if (auto grp = it.pObject->getExtension()) { - std::vector objs = grp->getObjects(); - for (auto obj : objs) { - ViewProvider* view = Application::Instance->getViewProvider(obj); - setRandomColor(view); + if (allowToChangeColor(it.pObject)) { + std::vector objs = grp->getObjects(); + for (auto obj : objs) { + ViewProvider* view = Application::Instance->getViewProvider(obj); + setRandomColor(view); + } } } } diff --git a/src/Gui/Quarter/QuarterWidgetP.cpp b/src/Gui/Quarter/QuarterWidgetP.cpp index 5f3267e5c8..7771c4b79b 100644 --- a/src/Gui/Quarter/QuarterWidgetP.cpp +++ b/src/Gui/Quarter/QuarterWidgetP.cpp @@ -169,13 +169,22 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co for (int i = 0; i < cachecontext_list->getLength(); i++) { if ((*cachecontext_list)[i] == context) { - // set the context while calling destructingContext() (might trigger OpenGL calls) - const_cast (widget)->makeCurrent(); - // fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818 - (void) cc_glglue_instance(context->id); + QtGLContext* glcontext = widget->context(); + if (glcontext) { + // set the context while calling destructingContext() (might trigger OpenGL calls) + if (glcontext->isValid()) { + const_cast (widget)->makeCurrent(); + } + // fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818 + (void) cc_glglue_instance(context->id); + } cachecontext_list->removeFast(i); SoContextHandler::destructingContext(context->id); - const_cast (widget)->doneCurrent(); + if (glcontext) { + if (glcontext->isValid()) { + const_cast (widget)->doneCurrent(); + } + } delete context; return; } diff --git a/src/Gui/TaskView/TaskImage.cpp b/src/Gui/TaskView/TaskImage.cpp index 0480fd8aa1..1e2cbaf509 100644 --- a/src/Gui/TaskView/TaskImage.cpp +++ b/src/Gui/TaskView/TaskImage.cpp @@ -204,16 +204,20 @@ void TaskImage::scaleImage(double factor) void TaskImage::startScale() { - scale->activate(); - ui->pushButtonScale->hide(); - ui->groupBoxCalibration->show(); - ui->pushButtonApply->setEnabled(false); + if (scale) { + scale->activate(); + ui->pushButtonScale->hide(); + ui->groupBoxCalibration->show(); + ui->pushButtonApply->setEnabled(false); + } } void TaskImage::acceptScale() { - scaleImage(scale->getScaleFactor()); - rejectScale(); + if (scale) { + scaleImage(scale->getScaleFactor()); + rejectScale(); + } } void TaskImage::enableApplyBtn() @@ -223,9 +227,11 @@ void TaskImage::enableApplyBtn() void TaskImage::rejectScale() { - scale->deactivate(); - ui->pushButtonScale->show(); - ui->groupBoxCalibration->hide(); + if (scale) { + scale->deactivate(); + ui->pushButtonScale->show(); + ui->groupBoxCalibration->hide(); + } } void TaskImage::onInteractiveScale() diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index e4ca175b20..11fbdc2a5a 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -853,15 +853,13 @@ ToolBarItem* StdWorkbench::setupCommandBars() const DockWindowItems* StdWorkbench::setupDockWindows() const { auto root = new DockWindowItems(); - root->addDockWidget("Std_ToolBox", Qt::RightDockWidgetArea, false, false); - //root->addDockWidget("Std_HelpView", Qt::RightDockWidgetArea, true, false); root->addDockWidget("Std_TreeView", Qt::LeftDockWidgetArea, true, false); root->addDockWidget("Std_PropertyView", Qt::LeftDockWidgetArea, true, false); root->addDockWidget("Std_SelectionView", Qt::LeftDockWidgetArea, false, false); root->addDockWidget("Std_ComboView", Qt::LeftDockWidgetArea, true, true); root->addDockWidget("Std_TaskView", Qt::LeftDockWidgetArea, true, true); - root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, true); - root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, true, true); + root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, false, true); + root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, false, true); //Dagview through parameter. ParameterGrp::handle group = App::GetApplication().GetUserParameter(). diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index c086afbf9b..19d9360d72 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -904,8 +904,10 @@ CmdMeshTrimByPlane::CmdMeshTrimByPlane() void CmdMeshTrimByPlane::activated(int) { - doCommand(Doc, - "import MeshPartGui, FreeCADGui\nFreeCADGui.runCommand('MeshPart_TrimByPlane')\n"); + const char* cmd = "import MeshPartGui\n" + "import FreeCADGui\n" + "FreeCADGui.runCommand('MeshPart_TrimByPlane')\n"; + runCommand(Doc, cmd); } bool CmdMeshTrimByPlane::isActive() @@ -935,8 +937,10 @@ CmdMeshSectionByPlane::CmdMeshSectionByPlane() void CmdMeshSectionByPlane::activated(int) { - doCommand(Doc, - "import MeshPartGui, FreeCADGui\nFreeCADGui.runCommand('MeshPart_SectionByPlane')\n"); + const char* cmd = "import MeshPartGui\n" + "import FreeCADGui\n" + "FreeCADGui.runCommand('MeshPart_SectionByPlane')\n"; + runCommand(Doc, cmd); } bool CmdMeshSectionByPlane::isActive() @@ -966,8 +970,10 @@ CmdMeshCrossSections::CmdMeshCrossSections() void CmdMeshCrossSections::activated(int) { - doCommand(Doc, - "import MeshPartGui, FreeCADGui\nFreeCADGui.runCommand('MeshPart_CrossSections')\n"); + const char* cmd = "import MeshPartGui\n" + "import FreeCADGui\n" + "FreeCADGui.runCommand('MeshPart_CrossSections')\n"; + runCommand(Doc, cmd); } bool CmdMeshCrossSections::isActive() diff --git a/src/Mod/MeshPart/Gui/Command.cpp b/src/Mod/MeshPart/Gui/Command.cpp index 9e3b6cb0c5..1934ad5b25 100644 --- a/src/Mod/MeshPart/Gui/Command.cpp +++ b/src/Mod/MeshPart/Gui/Command.cpp @@ -230,7 +230,8 @@ void CmdMeshPartSection::activated(int) for (auto it : docObj) { const Mesh::MeshObject* mesh = static_cast(it)->Mesh.getValuePtr(); std::vector polylines; - mesh->crossSections(sections, polylines); + const float minSectionLength = 1e-7F; + mesh->crossSections(sections, polylines, minSectionLength); for (const auto& it2 : polylines) { for (const auto& it3 : it2) { diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 5edc2a807a..05624eb89e 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -24,9 +24,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #endif #include @@ -45,20 +45,28 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskThicknessParameters */ -TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent) +TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp* DressUpView, QWidget* parent) : TaskDressUpParameters(DressUpView, false, true, parent) , ui(new Ui_TaskThicknessParameters) +{ + addContainerWidget(); + initControls(); +} + +void TaskThicknessParameters::addContainerWidget() { // we need a separate container widget to add all controls to proxy = new QWidget(this); ui->setupUi(proxy); this->groupLayout()->addWidget(proxy); +} - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); +void TaskThicknessParameters::initControls() +{ + auto pcThickness = dynamic_cast(DressUpView->getObject()); double a = pcThickness->Value.getValue(); ui->Value->setMinimum(0.0); - ui->Value->setMaximum(89.99); ui->Value->setValue(a); ui->Value->selectAll(); QMetaObject::invokeMethod(ui->Value, "setFocus", Qt::QueuedConnection); @@ -73,54 +81,59 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie ui->checkIntersection->setChecked(i); std::vector strings = pcThickness->Base.getSubValues(); - for (const auto & string : strings) - { + for (const auto& string : strings) { ui->listWidgetReferences->addItem(QString::fromStdString(string)); } + setupConnections(); + + int mode = static_cast(pcThickness->Mode.getValue()); + ui->modeComboBox->setCurrentIndex(mode); + + int join = static_cast(pcThickness->Join.getValue()); + ui->joinComboBox->setCurrentIndex(join); + + if (strings.empty()) { + setSelectionMode(refSel); + } + else { + hideOnError(); + } +} + +void TaskThicknessParameters::setupConnections() +{ + // clang-format off QMetaObject::connectSlotsByName(this); connect(ui->Value, qOverload(&Gui::QuantitySpinBox::valueChanged), - this, &TaskThicknessParameters::onValueChanged); + this, &TaskThicknessParameters::onValueChanged); connect(ui->checkReverse, &QCheckBox::toggled, - this, &TaskThicknessParameters::onReversedChanged); + this, &TaskThicknessParameters::onReversedChanged); connect(ui->checkIntersection, &QCheckBox::toggled, - this, &TaskThicknessParameters::onIntersectionChanged); + this, &TaskThicknessParameters::onIntersectionChanged); connect(ui->buttonRefSel, &QToolButton::toggled, - this, &TaskThicknessParameters::onButtonRefSel); + this, &TaskThicknessParameters::onButtonRefSel); connect(ui->modeComboBox, qOverload(&QComboBox::currentIndexChanged), - this, &TaskThicknessParameters::onModeChanged); + this, &TaskThicknessParameters::onModeChanged); connect(ui->joinComboBox, qOverload(&QComboBox::currentIndexChanged), - this, &TaskThicknessParameters::onJoinTypeChanged); + this, &TaskThicknessParameters::onJoinTypeChanged); // Create context menu createDeleteAction(ui->listWidgetReferences); connect(deleteAction, &QAction::triggered, this, &TaskThicknessParameters::onRefDeleted); connect(ui->listWidgetReferences, &QListWidget::currentItemChanged, - this, &TaskThicknessParameters::setSelection); + this, &TaskThicknessParameters::setSelection); connect(ui->listWidgetReferences, &QListWidget::itemClicked, - this, &TaskThicknessParameters::setSelection); + this, &TaskThicknessParameters::setSelection); connect(ui->listWidgetReferences, &QListWidget::itemDoubleClicked, - this, &TaskThicknessParameters::doubleClicked); - - int mode = pcThickness->Mode.getValue(); - ui->modeComboBox->setCurrentIndex(mode); - - int join = pcThickness->Join.getValue(); - ui->joinComboBox->setCurrentIndex(join); - - if (strings.size() == 0) - setSelectionMode(refSel); - else - hideOnError(); + this, &TaskThicknessParameters::doubleClicked); + // clang-format on } void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& msg) { - // executed when the user selected something in the CAD object - // adds/deletes the selection accordingly - if (msg.Type == Gui::SelectionChanges::AddSelection) { if (selectionMode == refSel) { referenceSelected(msg, ui->listWidgetReferences); @@ -139,37 +152,41 @@ void TaskThicknessParameters::onRefDeleted() TaskDressUpParameters::deleteRef(ui->listWidgetReferences); } -void TaskThicknessParameters::onValueChanged(double angle) +PartDesign::Thickness* TaskThicknessParameters::onBeforeChange() { setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); setupTransaction(); - pcThickness->Value.setValue(angle); - pcThickness->getDocument()->recomputeFeature(pcThickness); + return dynamic_cast(DressUpView->getObject()); +} + +void TaskThicknessParameters::onAfterChange(PartDesign::Thickness* obj) +{ + obj->recomputeFeature(); // hide the thickness if there was a computation error hideOnError(); } -void TaskThicknessParameters::onJoinTypeChanged(int join) { - - setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); - setupTransaction(); - pcThickness->Join.setValue(join); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); +void TaskThicknessParameters::onValueChanged(double angle) +{ + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Value.setValue(angle); + onAfterChange(thickness); } -void TaskThicknessParameters::onModeChanged(int mode) { +void TaskThicknessParameters::onJoinTypeChanged(int join) +{ - setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); - setupTransaction(); - pcThickness->Mode.setValue(mode); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Join.setValue(join); + onAfterChange(thickness); +} + +void TaskThicknessParameters::onModeChanged(int mode) +{ + + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Mode.setValue(mode); + onAfterChange(thickness); } double TaskThicknessParameters::getValue() const @@ -177,14 +194,11 @@ double TaskThicknessParameters::getValue() const return ui->Value->value().getValue(); } -void TaskThicknessParameters::onReversedChanged(const bool on) { - setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); - setupTransaction(); - pcThickness->Reversed.setValue(on); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); +void TaskThicknessParameters::onReversedChanged(bool on) +{ + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Reversed.setValue(on); + onAfterChange(thickness); } bool TaskThicknessParameters::getReversed() const @@ -192,13 +206,11 @@ bool TaskThicknessParameters::getReversed() const return ui->checkReverse->isChecked(); } -void TaskThicknessParameters::onIntersectionChanged(const bool on) { - setButtons(none); - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); - pcThickness->Intersection.setValue(on); - pcThickness->getDocument()->recomputeFeature(pcThickness); - // hide the thickness if there was a computation error - hideOnError(); +void TaskThicknessParameters::onIntersectionChanged(bool on) +{ + PartDesign::Thickness* thickness = onBeforeChange(); + thickness->Intersection.setValue(on); + onAfterChange(thickness); } bool TaskThicknessParameters::getIntersection() const @@ -206,12 +218,14 @@ bool TaskThicknessParameters::getIntersection() const return ui->checkIntersection->isChecked(); } -int TaskThicknessParameters::getJoinType() const { +int TaskThicknessParameters::getJoinType() const +{ return ui->joinComboBox->currentIndex(); } -int TaskThicknessParameters::getMode() const { +int TaskThicknessParameters::getMode() const +{ return ui->modeComboBox->currentIndex(); } @@ -223,17 +237,17 @@ TaskThicknessParameters::~TaskThicknessParameters() Gui::Selection().rmvSelectionGate(); } catch (const Py::Exception&) { - Base::PyException e; // extract the Python error text + Base::PyException e; // extract the Python error text e.ReportException(); } } -bool TaskThicknessParameters::event(QEvent *e) +bool TaskThicknessParameters::event(QEvent* e) { return TaskDressUpParameters::KeyEvent(e); } -void TaskThicknessParameters::changeEvent(QEvent *e) +void TaskThicknessParameters::changeEvent(QEvent* e) { TaskBox::changeEvent(e); if (e->type() == QEvent::LanguageChange) { @@ -243,9 +257,10 @@ void TaskThicknessParameters::changeEvent(QEvent *e) void TaskThicknessParameters::apply() { - //Alert user if he created an empty feature - if (ui->listWidgetReferences->count() == 0) + // Alert user if he created an empty feature + if (ui->listWidgetReferences->count() == 0) { Base::Console().Warning(tr("Empty thickness created !\n").toStdString().c_str()); + } } //************************************************************************** @@ -253,48 +268,32 @@ void TaskThicknessParameters::apply() // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgThicknessParameters::TaskDlgThicknessParameters(ViewProviderThickness *DressUpView) +TaskDlgThicknessParameters::TaskDlgThicknessParameters(ViewProviderThickness* DressUpView) : TaskDlgDressUpParameters(DressUpView) { - parameter = new TaskThicknessParameters(DressUpView); + parameter = new TaskThicknessParameters(DressUpView); Content.push_back(parameter); } TaskDlgThicknessParameters::~TaskDlgThicknessParameters() = default; -//==== calls from the TaskView =============================================================== - - -//void TaskDlgThicknessParameters::open() -//{ -// // a transaction is already open at creation time of the draft -// if (!Gui::Command::hasPendingCommand()) { -// QString msg = QObject::tr("Edit draft"); -// Gui::Command::openCommand((const char*)msg.toUtf8()); -// } -//} -// -//void TaskDlgThicknessParameters::clicked(int) -//{ -// -//} - bool TaskDlgThicknessParameters::accept() { auto obj = vp->getObject(); - if (!obj->isError()) + if (!obj->isError()) { parameter->showObject(); + } parameter->apply(); - TaskThicknessParameters* draftparameter = static_cast(parameter); + auto draftparameter = dynamic_cast(parameter); - FCMD_OBJ_CMD(obj,"Value = " << draftparameter->getValue()); - FCMD_OBJ_CMD(obj,"Reversed = " << draftparameter->getReversed()); - FCMD_OBJ_CMD(obj,"Mode = " << draftparameter->getMode()); - FCMD_OBJ_CMD(obj,"Intersection = " << draftparameter->getIntersection()); - FCMD_OBJ_CMD(obj,"Join = " << draftparameter->getJoinType()); + FCMD_OBJ_CMD(obj, "Value = " << draftparameter->getValue()); + FCMD_OBJ_CMD(obj, "Reversed = " << draftparameter->getReversed()); + FCMD_OBJ_CMD(obj, "Mode = " << draftparameter->getMode()); + FCMD_OBJ_CMD(obj, "Intersection = " << draftparameter->getIntersection()); + FCMD_OBJ_CMD(obj, "Join = " << draftparameter->getJoinType()); return TaskDlgDressUpParameters::accept(); } diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h index 7d16706a98..35c2194044 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.h +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.h @@ -29,14 +29,20 @@ class Ui_TaskThicknessParameters; -namespace PartDesignGui { +namespace PartDesign +{ +class Thickness; +} -class TaskThicknessParameters : public TaskDressUpParameters +namespace PartDesignGui +{ + +class TaskThicknessParameters: public TaskDressUpParameters { Q_OBJECT public: - explicit TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent=nullptr); + explicit TaskThicknessParameters(ViewProviderDressUp* DressUpView, QWidget* parent = nullptr); ~TaskThicknessParameters() override; void apply() override; @@ -44,34 +50,41 @@ public: double getValue() const; bool getReversed() const; bool getIntersection() const; - int getMode() const; - int getJoinType() const; + int getMode() const; + int getJoinType() const; private Q_SLOTS: void onValueChanged(double angle); void onModeChanged(int mode); void onJoinTypeChanged(int join); - void onReversedChanged(bool reversed); - void onIntersectionChanged(bool intersection); + void onReversedChanged(bool on); + void onIntersectionChanged(bool on); void onRefDeleted() override; protected: void setButtons(const selectionModes mode) override; - bool event(QEvent *e) override; - void changeEvent(QEvent *e) override; + bool event(QEvent* e) override; + void changeEvent(QEvent* e) override; void onSelectionChanged(const Gui::SelectionChanges& msg) override; +private: + void addContainerWidget(); + void initControls(); + void setupConnections(); + PartDesign::Thickness* onBeforeChange(); + void onAfterChange(PartDesign::Thickness* obj); + private: std::unique_ptr ui; }; /// simulation dialog for the TaskView -class TaskDlgThicknessParameters : public TaskDlgDressUpParameters +class TaskDlgThicknessParameters: public TaskDlgDressUpParameters { Q_OBJECT public: - explicit TaskDlgThicknessParameters(ViewProviderThickness *ThicknessView); + explicit TaskDlgThicknessParameters(ViewProviderThickness* ThicknessView); ~TaskDlgThicknessParameters() override; public: @@ -79,6 +92,6 @@ public: bool accept() override; }; -} //namespace PartDesignGui +} // namespace PartDesignGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif // GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index aa78a19e97..79947520cf 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -427,7 +427,6 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop) { if (prop == &Visibility || prop == &Selectable || prop == &DisplayModeBody || - prop == &ShapeAppearance || prop == &PointColorArray || prop == &LineColorArray) { return; diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 651c1fae1e..0c4b196d2e 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -68,111 +68,18 @@ namespace sp = std::placeholders; /// @namespace PartDesignGui @class Workbench TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench) -Workbench::Workbench() { -} +Workbench::Workbench() = default; -Workbench::~Workbench() { +Workbench::~Workbench() +{ WorkflowManager::destruct(); } -void Workbench::_switchToDocument(const App::Document* /*doc*/) -{ -// TODO Commented out for thurther remove or rewrite (2015-09-04, Fat-Zer) -// if (doc == NULL) return; -// -// PartDesign::Body* activeBody = NULL; -// std::vector bodies = doc->getObjectsOfType(PartDesign::Body::getClassTypeId()); -// -// // No tip, so build up structure or migrate -// if (!doc->Tip.getValue()) -// { -// ;/*if (doc->countObjects() == 0){ -// buildDefaultPartAndBody(doc); -// activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); -// assert(activeBody); -// } else { -// // empty document with no tip, so do migration -// _doMigration(doc); -// activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); -// assert(activeBody); -// } -// */ -// } -// else -// { -// App::Part *docPart = dynamic_cast(doc->Tip.getValue()); -// if (docPart) { -// App::Part *viewPart = Gui::Application::Instance->activeView()->getActiveObject("Part"); -// if (viewPart != docPart) -// Gui::Application::Instance->activeView()->setActiveObject(docPart, "Part"); -// //if (docPart->countObjectsOfType(PartDesign::Body::getClassTypeId()) < 1) -// // setUpPart(docPart); -// PartDesign::Body *tempBody = dynamic_cast (docPart->getObjectsOfType(PartDesign::Body::getClassTypeId()).front()); -// if (tempBody) { -// PartDesign::Body *viewBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); -// activeBody = viewBody; -// if (!viewBody) -// activeBody = tempBody; -// else if (!docPart->hasObject(viewBody)) -// activeBody = tempBody; -// -// if (activeBody != viewBody) -// Gui::Application::Instance->activeView()->setActiveObject(activeBody, PDBODYKEY); -// } -// } -// } -// -// /*if (activeBody == NULL) { -// QMessageBox::critical(Gui::getMainWindow(), QObject::tr("Could not create body"), -// QObject::tr("No body was found in this document, and none could be created. Please report this bug." -// "We recommend you do not use this document with the PartDesign workbench until the bug has been fixed." -// )); -// }*/ -} - -void Workbench::slotActiveDocument(const Gui::Document& /*Doc*/) -{ -// _switchToDocument(Doc.getDocument()); -} - -void Workbench::slotNewDocument(const App::Document& /*Doc*/) -{ -// _switchToDocument(&Doc); -} - -void Workbench::slotFinishRestoreDocument(const App::Document& /*Doc*/) -{ -// _switchToDocument(&Doc); -} - -void Workbench::slotDeleteDocument(const App::Document&) -{ - //ActivePartObject = 0; - //ActiveGuiDoc = 0; - //ActiveAppDoc = 0; - //ActiveVp = 0; -} -/* - This does not work for Std_DuplicateSelection: - Tree.cpp gives: "Cannot reparent unknown object", probably because the signalNewObject is emitted - before the duplication of the object has been completely finished - -void Workbench::slotNewObject(const App::DocumentObject& obj) -{ - if ((obj.getDocument() == ActiveAppDoc) && (ActivePartObject != NULL)) { - // Add the new object to the active Body - // Note: Will this break Undo? But how else can we catch Edit->Duplicate selection? - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", - ActivePartObject->getNameInDocument(), obj.getNameInDocument()); - } -} -*/ - void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const { auto selection = Gui::Selection().getSelection(); // Add move Tip Command - if ( !selection.empty() ) { + if (!selection.empty()) { App::DocumentObject *feature = selection.front().pObject; PartDesign::Body *body = nullptr; @@ -434,7 +341,6 @@ void Workbench::activated() "PartDesign_Mirrored", "PartDesign_LinearPattern", "PartDesign_PolarPattern", -// "PartDesign_Scaled", "PartDesign_MultiTransform", nullptr}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( @@ -444,37 +350,18 @@ void Workbench::activated() "PartDesign_MultiTransform" )); - // make the previously used active Body active again - //PartDesignGui::ActivePartObject = NULL; - _switchToDocument(App::GetApplication().getActiveDocument()); - addTaskWatcher(Watcher); if(App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign")->GetBool("SwitchToTask", true)) Gui::Control().showTaskView(); - - //NOLINTBEGIN - // Let us be notified when a document is activated, so that we can update the ActivePartObject - activeDoc = Gui::Application::Instance->signalActiveDocument.connect(std::bind(&Workbench::slotActiveDocument, this, sp::_1)); - createDoc = App::GetApplication().signalNewDocument.connect(std::bind(&Workbench::slotNewDocument, this, sp::_1)); - finishDoc = App::GetApplication().signalFinishRestoreDocument.connect(std::bind(&Workbench::slotFinishRestoreDocument, this, sp::_1)); - deleteDoc = App::GetApplication().signalDeleteDocument.connect(std::bind(&Workbench::slotDeleteDocument, this, sp::_1)); - //NOLINTEND } void Workbench::deactivated() { - // Let us be notified when a document is activated, so that we can update the ActivePartObject - activeDoc.disconnect(); - createDoc.disconnect(); - finishDoc.disconnect(); - deleteDoc.disconnect(); - removeTaskWatcher(); // reset the active Body Gui::Command::doCommand(Gui::Command::Doc,"import PartDesignGui"); Gui::Workbench::deactivated(); - } Gui::MenuItem* Workbench::setupMenuBar() const @@ -536,7 +423,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "PartDesign_LinearPattern" << "PartDesign_PolarPattern" << "PartDesign_MultiTransform"; -// << "PartDesign_Scaled" // dressups Gui::MenuItem* dressups = new Gui::MenuItem; @@ -572,7 +458,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Separator" << "Part_CheckGeometry" << "Separator" - << "PartDesign_Migrate" << "PartDesign_Sprocket"; // For 0.13 a couple of python packages like numpy, matplotlib and others @@ -650,16 +535,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const *part << "PartDesign_Mirrored" << "PartDesign_LinearPattern" << "PartDesign_PolarPattern" - // << "PartDesign_Scaled" << "PartDesign_MultiTransform"; return root; } - -Gui::ToolBarItem* Workbench::setupCommandBars() const -{ - // Part tools - Gui::ToolBarItem* root = new Gui::ToolBarItem; - return root; -} - diff --git a/src/Mod/PartDesign/Gui/Workbench.h b/src/Mod/PartDesign/Gui/Workbench.h index 5138f78e02..af2bf5137b 100644 --- a/src/Mod/PartDesign/Gui/Workbench.h +++ b/src/Mod/PartDesign/Gui/Workbench.h @@ -30,8 +30,6 @@ namespace Gui { class MenuItem; -class Document; -class ViewProviderDocumentObject; } @@ -48,7 +46,7 @@ public: Workbench(); ~Workbench() override; - /** Run some actions when the workbench gets activated. */ + /** Run some actions when the workbench gets activated. */ void activated() override; /** Run some actions when the workbench gets deactivated. */ void deactivated() override; @@ -57,29 +55,8 @@ public: void setupContextMenu(const char* recipient, Gui::MenuItem*) const override; protected: - Gui::MenuItem* setupMenuBar() const override; - Gui::ToolBarItem* setupToolBars() const override; - Gui::ToolBarItem* setupCommandBars() const override; - -private: - /// Refresh the Body's highlighting when a document becomes active - void slotActiveDocument(const Gui::Document&); - /// Refresh the highlighting. Migrate legacy documents on loading - void slotFinishRestoreDocument(const App::Document&); - /// Ensure that there are base planes and a body in a new document - void slotNewDocument(const App::Document&); - /// Update the ActivePartObject etc. when a document is closed - void slotDeleteDocument(const App::Document&); - // Add new objects to the body, if appropriate - //void slotNewObject(const App::DocumentObject& obj); - - void _switchToDocument(const App::Document* doc); - -private: - boost::signals2::connection activeDoc; - boost::signals2::connection createDoc; - boost::signals2::connection finishDoc; - boost::signals2::connection deleteDoc; + Gui::MenuItem* setupMenuBar() const override; + Gui::ToolBarItem* setupToolBars() const override; }; } // namespace PartDesignGui diff --git a/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp b/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp index 6cc6efaac8..152e10bd2b 100644 --- a/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp +++ b/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp @@ -91,7 +91,7 @@ void ExternalGeometryFacade::initExtensions() getGeo()->setExtension(std::make_unique()); // Create getExtension - Base::Console().Warning("%s\nSketcher External Geometry without Geometry Extension: %s \n", + Base::Console().Warning("Sketcher External Geometry without Geometry Extension: %s \n", boost::uuids::to_string(Geo->getTag()).c_str()); } @@ -101,7 +101,7 @@ void ExternalGeometryFacade::initExtensions() std::make_unique()); // Create getExtension Base::Console().Warning( - "%s\nSketcher External Geometry without ExternalGeometryExtension: %s \n", + "Sketcher External Geometry without ExternalGeometryExtension: %s \n", boost::uuids::to_string(Geo->getTag()).c_str()); } diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index e730ca29f0..241bdf30e9 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -1785,7 +1785,7 @@ PROPERTY_SOURCE_TEMPLATE(Spreadsheet::SheetPython, Spreadsheet::Sheet) template<> const char* Spreadsheet::SheetPython::getViewProviderName() const { - return "SpreadsheetGui::ViewProviderSheet"; + return "SpreadsheetGui::ViewProviderSheetPython"; } template<> PyObject* Spreadsheet::SheetPython::getPyObject() diff --git a/src/Mod/Start/Gui/Manipulator.cpp b/src/Mod/Start/Gui/Manipulator.cpp index 1682bb9cda..03522ada4e 100644 --- a/src/Mod/Start/Gui/Manipulator.cpp +++ b/src/Mod/Start/Gui/Manipulator.cpp @@ -56,10 +56,9 @@ void CmdStart::activated(int iMsg) { Q_UNUSED(iMsg); auto mw = Gui::getMainWindow(); - auto doc = Gui::Application::Instance->activeDocument(); auto existingView = mw->findChild(QLatin1String("StartView")); if (!existingView) { - existingView = gsl::owner(new StartGui::StartView(doc, mw)); + existingView = gsl::owner(new StartGui::StartView(mw)); mw->addWindow(existingView); // Transfers ownership } Gui::getMainWindow()->setActiveWindow(existingView); diff --git a/src/Mod/Start/Gui/StartView.cpp b/src/Mod/Start/Gui/StartView.cpp index 432c469bea..5232c55ad3 100644 --- a/src/Mod/Start/Gui/StartView.cpp +++ b/src/Mod/Start/Gui/StartView.cpp @@ -100,8 +100,8 @@ gsl::owner createNewButton(const NewButton& newButton) } // namespace -StartView::StartView(Gui::Document* pcDocument, QWidget* parent) - : Gui::MDIView(pcDocument, parent) +StartView::StartView(QWidget* parent) + : Gui::MDIView(nullptr, parent) , _contents(new QScrollArea(parent)) , _newFileLabel {nullptr} , _examplesLabel {nullptr} diff --git a/src/Mod/Start/Gui/StartView.h b/src/Mod/Start/Gui/StartView.h index 33beea9980..fe2d33167c 100644 --- a/src/Mod/Start/Gui/StartView.h +++ b/src/Mod/Start/Gui/StartView.h @@ -54,7 +54,7 @@ class StartGuiExport StartView: public Gui::MDIView TYPESYSTEM_HEADER_WITH_OVERRIDE(); // NOLINT public: - StartView(Gui::Document* pcDocument, QWidget* parent); + StartView(QWidget* parent); const char* getName() const override {