Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Modeler] Compatible Modeler project with last version #4673

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ template <class DataTypes>
void FixedProjectiveConstraint<DataTypes>::checkIndices()
{
// Check value of given indices
if (!this->mstate.get())
{
msg_warning() << "Missing mstate, cannot check indices .!";
return;
}
Index maxIndex=this->mstate->getSize();

const SetIndexArray & indices = d_indices.getValue();
Expand Down
23 changes: 14 additions & 9 deletions Sofa/GUI/Qt/src/sofa/gui/qt/DataWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ DataWidget::DataWidget(QWidget* parent,const char* name, MyData* d)
, m_toFill(false)
{
this->setObjectName(name);


}

DataWidget::~DataWidget()
Expand Down Expand Up @@ -211,23 +213,26 @@ QDisplayDataInfoWidget::QDisplayDataInfoWidget(QWidget* parent, const std::strin
if (!ownerClass.empty())
helper_button->setToolTip( ("Data from "+ownerClass).c_str());
}

linkpath_edit = new QLineEdit(this);
linkpath_edit->setContentsMargins(2, 0, 0, 0);
linkpath_edit->setReadOnly(!modifiable);
layout->addWidget(linkpath_edit);
if(modifyObjectFlags.PROPERTY_WIDGET_FLAG)
connect(linkpath_edit, &QLineEdit::textChanged, [=](){ WidgetDirty(); });
else
connect(linkpath_edit, &QLineEdit::editingFinished, this, &QDisplayDataInfoWidget::linkEdited);

if(data->getParent())
{
const std::string linkvalue = data->getParent()->getLinkPath();
linkpath_edit = new QLineEdit(this);
linkpath_edit->setContentsMargins(2, 0, 0, 0);
linkpath_edit->setText(QString(linkvalue.c_str()));
linkpath_edit->setReadOnly(!modifiable);
layout->addWidget(linkpath_edit);
linkpath_edit->setVisible(!linkvalue.empty());
if(modifyObjectFlags.PROPERTY_WIDGET_FLAG)
connect(linkpath_edit, &QLineEdit::textChanged, [=](){ WidgetDirty(); });
else
connect(linkpath_edit, &QLineEdit::editingFinished, this, &QDisplayDataInfoWidget::linkEdited);
}
else
{
linkpath_edit=nullptr;
linkpath_edit->setText("");
linkpath_edit->setVisible(false);
}
}

Expand Down
5 changes: 4 additions & 1 deletion Sofa/GUI/Qt/src/sofa/gui/qt/SofaSceneGraphWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ class SOFA_GUI_QT_API SofaSceneGraphWidget : public QTreeWidget
{
Q_OBJECT
public:
SofaSceneGraphWidget(QWidget* parent) : QTreeWidget(parent){}
SofaSceneGraphWidget(QWidget* parent) : QTreeWidget(parent)
{
m_isLocked = false;
}
~SofaSceneGraphWidget(){}

void lock();
Expand Down
13 changes: 9 additions & 4 deletions Sofa/framework/Core/src/sofa/core/objectmodel/AspectPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@
#include <sofa/helper/system/thread/CircularQueue.inl>
#include <iostream>

namespace sofa
{

namespace core
{

namespace sofa::core::objectmodel
namespace objectmodel
{

/**
Expand Down Expand Up @@ -220,8 +225,8 @@ bool AspectBuffer::pop(AspectRef& id)
return true;
}

} // namespace sofa::core::objectmodel


} // namespace objectmodel

} // namespace core

} // namespace sofa
31 changes: 24 additions & 7 deletions Sofa/framework/Core/src/sofa/core/objectmodel/Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,17 +637,32 @@ void Base::writeDatas (std::ostream& out, const std::string& separator)
for(VecData::const_iterator iData = m_vecData.begin(); iData != m_vecData.end(); ++iData)
{
const BaseData* field = *iData;
if (!field->getLinkPath().empty() )

if (field->getParent())
{
out << separator << field->getName() << "=\""<< xmlencode(field->getLinkPath()) << "\" ";
// out << separator << field->getName() << "=\"" << xmlencode(field->getLinkPath()) << "\" ";
std::string linkPath = field->getParent()->getLinkPath();
if(!linkPath.empty())
out << separator << field->getName() << "=\"" << xmlencode(linkPath) << "\" ";
}
else
{
if(field->isPersistent() && field->isSet())
std::string val = field->getValueString();
std::string fieldname = field->getName();
bool isFullTrim = false;
bool isset = field->isSet();
if(isset && fieldname != "parents")
{
std::string val = field->getValueString();
if (!val.empty())
out << separator << field->getName() << "=\""<< xmlencode(val) << "\" ";
std::string checkSpace = field->getValueString();
checkSpace.erase(remove_if(checkSpace.begin(), checkSpace.end(), isspace), checkSpace.end());
if(checkSpace.empty())
{
isFullTrim = true;
}
if (!val.empty() && !isFullTrim)
{
out << separator << fieldname << "=\""<< xmlencode(val) << "\" ";
}
}
}
}
Expand All @@ -657,8 +672,10 @@ void Base::writeDatas (std::ostream& out, const std::string& separator)
if(link->storePath())
{
std::string val = link->getValueString();
if (!val.empty())
if (!val.empty() && link->getName() != "parents")
{
out << separator << link->getName() << "=\""<< xmlencode(val) << "\" ";
}
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
******************************************************************************/
#include <sofa/core/objectmodel/BaseClass.h>

namespace sofa
{

namespace core
{

namespace sofa::core::objectmodel
namespace objectmodel
{

BaseClass* DeprecatedBaseClass::GetSingleton()
Expand All @@ -49,9 +54,9 @@ DeprecatedBaseClass::DeprecatedBaseClass()
}


} // namespace sofa::core::objectmodel


} // namespace objectmodel

} // namespace core

} // namespace sofa

24 changes: 20 additions & 4 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,20 @@ bool BaseData::setParent(BaseData* parent, const std::string& path)

std::string BaseData::getLinkPath() const
{
if(m_owner)
return "@"+m_owner->getPathName()+"."+getName();
// std::string ownerPathName = m_owner->getPathName();
// bool isStrFine = false;
// for(unsigned int i=0 ; i < ownerPathName.length() ; i++)
// {
// if(ownerPathName[i] != '/')
// {
// isStrFine = true;
// }
// }
if(m_owner /*&& ownerPathName != "/"*/)
{
std::string linkPathStr = "@"+m_owner->getPathName()+"."+getName();
return linkPathStr;
}
return "";
}

Expand All @@ -158,16 +170,20 @@ void BaseData::doDelInput(DDGNode* n)
void BaseData::update()
{
cleanDirty();
for (DDGNode* input : inputs)
for(DDGLinkIterator it=inputs.begin(); it!=inputs.end(); ++it)
{
input->updateIfDirty();
(*it)->updateIfDirty();
}

/// Check if there is a parent (so a predecessor in the DDG), if so
/// update the internal value.
const auto parent = parentData.resolvePathAndGetTarget();
if (parent)
{
#ifdef SOFA_DDG_TRACE
if (m_owner)
dmsg_warning(m_owner) << "Data " << m_name << ": update from parent " << parentBaseData->m_name;
#endif
updateValueFromLink(parent);
// If the value is dirty clean it
if(this->isDirty())
Expand Down
2 changes: 1 addition & 1 deletion Sofa/framework/Core/src/sofa/core/objectmodel/BaseData.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class SOFA_CORE_API BaseData : public DDGNode
/// True if this %Data is set, i.e. its value is different from the default value
bool m_isSet;
/// Flags indicating the purpose and behaviour of this %Data
DataFlags m_dataFlags;
DataFlags m_dataFlags = FLAG_PERSISTENT;
/// Return the Base component owning this %Data
Base* m_owner {nullptr};
/// Data name within the Base component
Expand Down
22 changes: 18 additions & 4 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
#include <sofa/core/collision/Pipeline.h>
#include <sofa/core/visual/VisualLoop.h>

namespace sofa
{

namespace core
{

namespace sofa::core::objectmodel
namespace objectmodel
{

BaseNode::BaseNode()
Expand Down Expand Up @@ -94,6 +99,15 @@ std::string BaseNode::internalGetPathName() const {
// no smarter choice without breaking the "Node" heritage
str = parents[0]->internalGetPathName();
str += '/';
// bool strIsFine = false;
// for(unsigned int i=0 ; i < str.length() ; i++)
// {
// if(str[i] != '/')
// {
// strIsFine = true;
// }
// }
// if(strIsFine)
str += getName();
}
return str;
Expand All @@ -116,8 +130,8 @@ std::string BaseNode::getRootPath() const {
return str;
}

} // namespace sofa::core::objectmodel


} // namespace objectmodel

} // namespace core

} // namespace sofa
23 changes: 19 additions & 4 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
#include <iostream>


namespace sofa::core::objectmodel
namespace sofa
{

namespace core
{

namespace objectmodel
{

BaseObject::BaseObject()
Expand Down Expand Up @@ -363,13 +369,22 @@ std::string BaseObject::getPathName() const {
}

}
// bool strIsFine = false;
// for(unsigned int i=0 ; i < result.length() ; i++)
// {
// if(result[i] != '/')
// {
// strIsFine = true;
// }
// }
// if(strIsFine)
result += getName();
return result;
}

} // namespace sofa::core::objectmodel


} // namespace objectmodel

} // namespace core

} // namespace sofa

12 changes: 6 additions & 6 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ class SOFA_CORE_API BaseObject : public virtual Base

public:

/// the component can insert itself directly in the right sequence in the Node
/// so the Node does not have to test its type against all known types
/// \returns true if the component was inserted
/// the component can insert itseft direclty in the right sequence in the Node
/// so the Node does not have to test its type against every known types.
/// \returns true iff the component was inserted
virtual bool insertInNode( BaseNode* /*node*/ ) { return false; }

/// the component can remove itself directly in the right sequence in the Node
/// so the Node does not have to test its type against all known types
/// \returns true if the component was removed
/// the component can remove itseft direclty in the right sequence in the Node
/// so the Node does not have to test its type against every known types.
/// \returns true iff the component was removed
virtual bool removeInNode( BaseNode* /*node*/ ) { return false; }
};

Expand Down
13 changes: 9 additions & 4 deletions Sofa/framework/Core/src/sofa/core/objectmodel/ClassInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
******************************************************************************/
#include <sofa/core/objectmodel/ClassInfo.h>

namespace sofa
{

namespace core
{

namespace sofa::core::objectmodel
namespace objectmodel
{

std::map<sofa::helper::TypeInfo, ClassInfo*> ClassInfo::classes;
Expand All @@ -38,9 +43,9 @@ ClassInfo::~ClassInfo()
}


} // namespace sofa::core::objectmodel


} // namespace objectmodel

} // namespace core

} // namespace sofa

12 changes: 9 additions & 3 deletions Sofa/framework/Core/src/sofa/core/objectmodel/ComponentState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
#include <string>
#include <sofa/core/objectmodel/ComponentState.h>


namespace sofa::core::objectmodel
namespace sofa
{
namespace core
{
namespace objectmodel
{


Expand Down Expand Up @@ -60,5 +63,8 @@ std::istream& operator>>(std::istream& i, ComponentState& s)
return i;
}

}
} /// namespace objectmodel
} /// namespace core
} /// namespace sofa


Loading