Skip to content

Commit

Permalink
issue #2802: Set a name to coin rootnodes of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 15, 2016
1 parent 1ec381a commit b97f93c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Gui/SceneInspector.cpp
Expand Up @@ -97,7 +97,10 @@ void SceneModel::setNode(QModelIndex index, SoNode* node)
for (int i=0; i<group->getNumChildren();i++) {
SoNode* child = group->getChild(i);
setNode(this->index(i, 0, index), child);
this->setData(this->index(i, 1, index), QVariant(QString::fromLatin1(child->getName())));
// See ViewProviderDocumentObject::updateData
QByteArray name(child->getName());
name = QByteArray::fromPercentEncoding(name);
this->setData(this->index(i, 1, index), QVariant(QString::fromUtf8(name)));
}
}
// insert icon
Expand Down
9 changes: 5 additions & 4 deletions src/Gui/ViewProvider.cpp
Expand Up @@ -263,13 +263,14 @@ SbMatrix ViewProvider::convert(const Base::Matrix4D &rcMatrix) const
dMtrx[12],dMtrx[13],dMtrx[14], dMtrx[15]);
}

void ViewProvider::addDisplayMaskMode( SoNode *node, const char* type )
void ViewProvider::addDisplayMaskMode(SoNode *node, const char* type)
{
_sDisplayMaskModes[ type ] = pcModeSwitch->getNumChildren();
pcModeSwitch->addChild( node );
node->setName(type);
_sDisplayMaskModes[type] = pcModeSwitch->getNumChildren();
pcModeSwitch->addChild(node);
}

void ViewProvider::setDisplayMaskMode( const char* type )
void ViewProvider::setDisplayMaskMode(const char* type)
{
std::map<std::string, int>::const_iterator it = _sDisplayMaskModes.find( type );
if (it != _sDisplayMaskModes.end())
Expand Down
14 changes: 14 additions & 0 deletions src/Gui/ViewProviderDocumentObject.cpp
Expand Up @@ -24,6 +24,7 @@
#include "PreCompiled.h"

#ifndef _PreComp_
# include <QByteArray>
# include <qpixmap.h>
# include <Inventor/actions/SoSearchAction.h>
# include <Inventor/nodes/SoDrawStyle.h>
Expand Down Expand Up @@ -187,6 +188,19 @@ void ViewProviderDocumentObject::attach(App::DocumentObject *pcObj)
ext->extensionAttach(pcObj);
}

void ViewProviderDocumentObject::updateData(const App::Property* prop)
{
if (pcObject && prop == &pcObject->Label) {
// SoBase::setName() replaces characters that according to the
// VRML standard are invalid. To avoid the replacement we use
// the percent encoding.
QByteArray ba(pcObject->Label.getValue());
QByteArray name = ba.toPercentEncoding();
pcRoot->setName(name.constData());
}
ViewProvider::updateData(prop);
}

Gui::Document* ViewProviderDocumentObject::getDocument() const
{
App::Document* pAppDoc = pcObject->getDocument();
Expand Down
1 change: 1 addition & 0 deletions src/Gui/ViewProviderDocumentObject.h
Expand Up @@ -62,6 +62,7 @@ class GuiExport ViewProviderDocumentObject : public ViewProvider
App::PropertyBool Visibility;

virtual void attach(App::DocumentObject *pcObject);
virtual void updateData(const App::Property*);
/// Set the active mode, i.e. the first item of the 'Display' property.
void setActiveMode();
/// Hide the object in the view
Expand Down
3 changes: 3 additions & 0 deletions src/Gui/ViewProviderGeometryObject.cpp
Expand Up @@ -180,6 +180,9 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop)
Base::Placement p = static_cast<const App::PropertyPlacement*>(prop)->getValue();
updateTransform(p, pcTransform);
}
else {
ViewProviderDocumentObject::updateData(prop);
}
}

bool ViewProviderGeometryObject::doubleClicked(void)
Expand Down

0 comments on commit b97f93c

Please sign in to comment.