Skip to content

Commit

Permalink
Gui: track editing object placement change
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Dec 8, 2019
1 parent ceeb776 commit 719c11e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/Gui/Document.cpp
Expand Up @@ -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<const App::DocumentObject*> _editObjs;

Application* _pcAppWnd;
// the doc/Document
App::Document* _pcDocument;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand All @@ -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<View3DInventor *>(getActiveView());
if (activeView)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 719c11e

Please sign in to comment.