diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 38e6514709..4cc095cc4f 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -90,10 +90,14 @@ struct DocumentP bool _changeViewTouchDocument; int _editMode; ViewProvider* _editViewProvider; + App::DocumentObject* _editingObject; ViewProviderDocumentObject* _editViewProviderParent; std::string _editSubname; std::string _editSubElement; Base::Matrix4D _editingTransform; + View3DInventorViewer* _editingViewer; + std::set _editObjs; + Application* _pcAppWnd; // the doc/Document App::Document* _pcDocument; @@ -154,7 +158,9 @@ Document::Document(App::Document* pcDocument,Application * app) d->_pcAppWnd = app; d->_pcDocument = pcDocument; d->_editViewProvider = 0; + d->_editingObject = 0; d->_editViewProviderParent = 0; + d->_editingViewer = 0; d->_editMode = 0; // Setup the connections @@ -405,8 +411,16 @@ bool Document::setEdit(Gui::ViewProvider* p, int ModNum, const char *subname) FC_LOG("object '" << sobj->getFullName() << "' refuse to edit"); return false; } - if(view3d) + + auto sobjs = obj->getSubObjectList(subname); + d->_editObjs.clear(); + d->_editObjs.insert(sobjs.begin(),sobjs.end()); + d->_editingObject = sobj; + + if(view3d) { view3d->getViewer()->setEditingViewProvider(d->_editViewProvider,ModNum); + d->_editingViewer = view3d->getViewer(); + } Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog(); if (dlg) dlg->setDocumentName(this->getDocument()->getName()); @@ -422,6 +436,7 @@ const Base::Matrix4D &Document::getEditingTransform() const { } void Document::setEditingTransform(const Base::Matrix4D &mat) { + d->_editObjs.clear(); d->_editingTransform = mat; View3DInventor *activeView = dynamic_cast(getActiveView()); if (activeView) @@ -465,6 +480,9 @@ void Document::_resetEdit(void) App::GetApplication().closeActiveTransaction(); } d->_editViewProviderParent = 0; + d->_editingViewer = 0; + d->_editObjs.clear(); + d->_editingObject = 0; if(Application::Instance->editDocument() == this) Application::Instance->setEditDocument(0); } @@ -760,6 +778,21 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop if (viewProvider) { try { viewProvider->update(&Prop); + if(d->_editingViewer + && d->_editingObject + && d->_editViewProviderParent + && (Prop.isDerivedFrom(App::PropertyPlacement::getClassTypeId()) + || strstr(Prop.getName(),"Scale")) + && d->_editObjs.count(&Obj)) + { + Base::Matrix4D mat; + auto sobj = d->_editViewProviderParent->getObject()->getSubObject( + d->_editSubname.c_str(),0,&mat); + if(sobj == d->_editingObject && d->_editingTransform!=mat) { + d->_editingTransform = mat; + d->_editingViewer->setEditingTransform(d->_editingTransform); + } + } } catch(const Base::MemoryException& e) { FC_ERR("Memory exception in " << Obj.getFullName() << " thrown: " << e.what()); diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 0aeea68e8c..800ca145c0 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -569,6 +569,21 @@ const char *TreeWidget::getTreeName() const { return myName.c_str(); } +// reimpelement to select only objects in the active document +void TreeWidget::selectAll() { + auto gdoc = Application::Instance->getDocument( + App::GetApplication().getActiveDocument()); + if(!gdoc) + return; + auto itDoc = DocumentMap.find(gdoc); + if(itDoc == DocumentMap.end()) + return; + if(TreeParams::Instance()->RecordSelection()) + Gui::Selection().selStackPush(); + Gui::Selection().clearSelection(); + Gui::Selection().setSelection(gdoc->getDocument()->getName(),gdoc->getDocument()->getObjects()); +} + bool TreeWidget::isObjectShowable(App::DocumentObject *obj) { if(!obj || !obj->getNameInDocument()) return true; @@ -2696,29 +2711,18 @@ void TreeWidget::onItemSelectionChanged () auto selItems = selectedItems(); // do not allow document item multi-selection - auto itDoc = selItems.end(); - auto itObj = selItems.end(); - for(auto it=selItems.begin();it!=selItems.end();) { - auto item = *it; - if(item->type() == ObjectType) { - itObj = it; - if(itDoc!=selItems.end()) { - (*itDoc)->setSelected(false); - selItems.erase(itDoc); - itDoc = selItems.end(); - } - }else if(item->type() == DocumentType) { - if(itObj!=selItems.end()) { + if(selItems.size()) { + auto firstType = selItems.back()->type(); + for(auto it=selItems.begin();it!=selItems.end();) { + auto item = *it; + if((firstType==ObjectType && item->type()!=ObjectType) + || (firstType==DocumentType && item!=selItems.back())) + { item->setSelected(false); it = selItems.erase(it); - continue; - }else if(itDoc!=selItems.end()) { - (*itDoc)->setSelected(false); - selItems.erase(itDoc); - } - itDoc = it; + } else + ++it; } - ++it; } if(selItems.size()<=1) { @@ -4176,7 +4180,7 @@ DocumentObjectItem *DocumentItem::findItem( void DocumentItem::selectItems(SelectionReason reason) { const auto &sels = Selection().getSelection(pDocument->getDocument()->getName(),false); - bool sync = reason==SR_SELECT?false:true; + bool sync = (sels.size()>50 || reason==SR_SELECT)?false:true; for(const auto &sel : sels) findItemByObject(sync,sel.pObject,sel.SubName,true); diff --git a/src/Gui/Tree.h b/src/Gui/Tree.h index 2335ea4198..4da8e8f62e 100644 --- a/src/Gui/Tree.h +++ b/src/Gui/Tree.h @@ -108,6 +108,8 @@ public: void markItem(const App::DocumentObject* Obj,bool mark); void syncView(ViewProviderDocumentObject *vp); + virtual void selectAll() override; + const char *getTreeName() const; static void updateStatus(bool delay=true); diff --git a/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h b/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h index 491c3fc1fd..182d461e78 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusImp.h @@ -1,4 +1,4 @@ -/******************b******************************************************** +/*************************************************************************** * Copyright (c) 2017 FreeCAD Developers * * Author: Bernd Hahnebach * * Based on src/Mod/Fem/Gui/DlgSettingsFemCcx.h * diff --git a/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h b/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h index 0086946237..6c64638807 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemInOutVtkImp.h @@ -1,7 +1,7 @@ -/******************b******************************************************** +/*************************************************************************** * Copyright (c) 2018 FreeCAD Developers * * Author: Bernd Hahnebach * - * Based on src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusCcxImp.h * + * Based on src/Mod/Fem/Gui/DlgSettingsFemExportAbaqusCcxImp.h * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h index aa7fd66c31..ff2135d83f 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemMaterialImp.h @@ -1,7 +1,7 @@ /************************************************************************** * Copyright (c) 2018 FreeCAD Developers * * Author: Bernd Hahnebach * - * Based on src/Mod/Fem/Gui/DlgSettingsFemElmer.h * + * Based on src/Mod/Fem/Gui/DlgSettingsFemElmer.h * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index dc10f2253b..1024f99da4 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -344,18 +344,20 @@ void DrawView::handleChangedPropertyType( Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n"); // no idea } - } else if (prop->isDerivedFrom(App::PropertyLinkList::getClassTypeId()) - && strcmp(prop->getName(),"Source")==0) { + } + else if (prop->isDerivedFrom(App::PropertyLinkList::getClassTypeId()) + && strcmp(prop->getName(), "Source") == 0) { App::PropertyLinkGlobal glink; App::PropertyLink link; - if (strcmp(glink.getTypeId().getName(),TypeName) == 0) { //property in file is plg + if (strcmp(glink.getTypeId().getName(), TypeName) == 0) { //property in file is plg glink.setContainer(this); glink.Restore(reader); if (glink.getValue() != nullptr) { static_cast(prop)->setScope(App::LinkScope::Global); static_cast(prop)->setValue(glink.getValue()); } - } else if (strcmp(link.getTypeId().getName(),TypeName) == 0) { //property in file is pl + } + else if (strcmp(link.getTypeId().getName(), TypeName) == 0) { //property in file is pl link.setContainer(this); link.Restore(reader); if (link.getValue() != nullptr) { @@ -363,23 +365,36 @@ void DrawView::handleChangedPropertyType( static_cast(prop)->setValue(link.getValue()); } } + } // property X had App::PropertyFloat and was changed to App::PropertyLength - // sb PropertyDistance. some X,Y are relative to existing point on page - } else if (prop == &X && strcmp(TypeName, "App::PropertyFloat") == 0) { + // and later to PropertyDistance because some X,Y are relative to existing points on page + else if (prop == &X && strcmp(TypeName, "App::PropertyFloat") == 0) { App::PropertyFloat XProperty; XProperty.setContainer(this); // restore the PropertyFloat to be able to set its value XProperty.Restore(reader); X.setValue(XProperty.getValue()); - } else if (prop == &Y && strcmp(TypeName, "App::PropertyFloat") == 0) { + } + else if (prop == &X && strcmp(TypeName, "App::PropertyLength") == 0) { + App::PropertyLength X2Property; + X2Property.Restore(reader); + X.setValue(X2Property.getValue()); + } + else if (prop == &Y && strcmp(TypeName, "App::PropertyFloat") == 0) { App::PropertyFloat YProperty; YProperty.setContainer(this); YProperty.Restore(reader); Y.setValue(YProperty.getValue()); + } + else if (prop == &Y && strcmp(TypeName, "App::PropertyLength") == 0) { + App::PropertyLength Y2Property; + Y2Property.Restore(reader); + Y.setValue(Y2Property.getValue()); + } // property Rotation had App::PropertyFloat and was changed to App::PropertyAngle - } else if (prop == &Rotation && strcmp(TypeName, "App::PropertyFloat") == 0) { + else if (prop == &Rotation && strcmp(TypeName, "App::PropertyFloat") == 0) { App::PropertyFloat RotationProperty; RotationProperty.setContainer(this); RotationProperty.Restore(reader);