Part: make changing face colors independent of edit-mode implementation of a view provider
This commit is contained in:
@@ -2159,14 +2159,7 @@ CmdColorPerFace::CmdColorPerFace()
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Color per face");
|
||||
sToolTipText = QT_TR_NOOP("Set the color of each individual face "
|
||||
"of the selected object.\n"
|
||||
"\n"
|
||||
"At the moment, this command only works "
|
||||
"with objects which have not reimplemented\n"
|
||||
"their 'edit modes'; this means, it works "
|
||||
"with Part and PartDesign created objects,\n"
|
||||
"but not with most Draft or Arch objects. "
|
||||
"See issues #0477 and #1954 in the tracker.");
|
||||
"of the selected object.");
|
||||
sStatusTip = sToolTipText;
|
||||
sWhatsThis = "Part_ColorPerFace";
|
||||
sPixmap = "Part_ColorFace";
|
||||
@@ -2178,13 +2171,11 @@ void CmdColorPerFace::activated(int iMsg)
|
||||
if (getActiveGuiDocument()->getInEdit())
|
||||
getActiveGuiDocument()->resetEdit();
|
||||
std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId());
|
||||
if(sel.empty())
|
||||
if (sel.empty())
|
||||
return;
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(sel.front());
|
||||
// FIXME: Need a way to force 'Color' edit mode
|
||||
// #0000477: Proper interface for edit modes of view provider
|
||||
PartGui::ViewProviderPartExt* vp = dynamic_cast<PartGui::ViewProviderPartExt*>(Gui::Application::Instance->getViewProvider(sel.front()));
|
||||
if (vp)
|
||||
getActiveGuiDocument()->setEdit(vp, Gui::ViewProvider::Color);
|
||||
vp->changeFaceColors();
|
||||
}
|
||||
|
||||
bool CmdColorPerFace::isActive(void)
|
||||
|
||||
@@ -962,21 +962,26 @@ void ViewProviderPartExt::setupContextMenu(QMenu* menu, QObject* receiver, const
|
||||
act->setData(QVariant((int)ViewProvider::Color));
|
||||
}
|
||||
|
||||
bool ViewProviderPartExt::changeFaceColors()
|
||||
{
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg) {
|
||||
Gui::Control().showDialog(dlg);
|
||||
return false;
|
||||
}
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Control().showDialog(new TaskFaceColors(this));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderPartExt::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Color) {
|
||||
// When double-clicking on the item for this pad the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg) {
|
||||
Gui::Control().showDialog(dlg);
|
||||
return false;
|
||||
}
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Control().showDialog(new TaskFaceColors(this));
|
||||
return true;
|
||||
return changeFaceColors();
|
||||
}
|
||||
else {
|
||||
return Gui::ViewProviderGeometryObject::setEdit(ModNum);
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
App::PropertyMaterial LineMaterial;
|
||||
App::PropertyColorList LineColorArray;
|
||||
// Faces (Gui::ViewProviderGeometryObject::ShapeColor and Gui::ViewProviderGeometryObject::ShapeMaterial apply)
|
||||
App::PropertyColorList DiffuseColor;
|
||||
App::PropertyColorList DiffuseColor;
|
||||
|
||||
virtual void attach(App::DocumentObject *) override;
|
||||
virtual void setDisplayMode(const char* ModeName) override;
|
||||
@@ -97,6 +97,8 @@ public:
|
||||
virtual std::vector<std::string> getDisplayModes(void) const override;
|
||||
/// Update the view representation
|
||||
void reload();
|
||||
/// If no other task is pending it opens a dialog to allow to change face colors
|
||||
bool changeFaceColors();
|
||||
|
||||
virtual void updateData(const App::Property*) override;
|
||||
|
||||
|
||||
@@ -157,17 +157,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
<< "Part_Measure_Toggle_3D"
|
||||
<< "Part_Measure_Toggle_Delta";
|
||||
|
||||
// leave this for 0.14 until #0000477 is fixed
|
||||
|
||||
// According to #0477 and #1954
|
||||
// `Part_ColorPerFace` does not work with objects that reimplement
|
||||
// their edit modes, meaning it may work with Part and PartDesign
|
||||
// created objects but not with Draft and Arch objects.
|
||||
// However, it does not make much sense to keep it hidden;
|
||||
// having it available in the interface will allow more people
|
||||
// to use it, and maybe somebody will be able to investigate
|
||||
// and fix the issue.
|
||||
#if 1
|
||||
Gui::MenuItem* view = root->findItem("&View");
|
||||
if (view) {
|
||||
Gui::MenuItem* appr = view->findItem("Std_RandomColor");
|
||||
@@ -176,7 +165,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
face->setCommand("Part_ColorPerFace");
|
||||
view->insertItem(appr, face);
|
||||
}
|
||||
#endif
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user