Merge branch 'master' into feature/tool-bit-poc
This commit is contained in:
@@ -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;
|
||||
@@ -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<View3DInventor *>(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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/******************b********************************************************
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2017 FreeCAD Developers *
|
||||
* Author: Bernd Hahnebach <bernd@bimstatik.ch> *
|
||||
* Based on src/Mod/Fem/Gui/DlgSettingsFemCcx.h *
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/******************b********************************************************
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2018 FreeCAD Developers *
|
||||
* Author: Bernd Hahnebach <bernd@bimstatik.ch> *
|
||||
* 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. *
|
||||
* *
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**************************************************************************
|
||||
* Copyright (c) 2018 FreeCAD Developers *
|
||||
* Author: Bernd Hahnebach <bernd@bimstatik.ch> *
|
||||
* 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. *
|
||||
* *
|
||||
|
||||
@@ -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<App::PropertyLinkList*>(prop)->setScope(App::LinkScope::Global);
|
||||
static_cast<App::PropertyLinkList*>(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<App::PropertyLinkList*>(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);
|
||||
|
||||
Reference in New Issue
Block a user