Skip to content

Commit

Permalink
Store loaded subtypename in HopsanCore components
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Jan 23, 2024
1 parent d446f18 commit 9d29f3c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion HopsanGUI/CoreAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ void CoreSystemAccess::finalize()
mpCoreComponentSystem->finalize();
}

QString CoreSystemAccess::createComponent(QString type, QString name)
QString CoreSystemAccess::createComponent(QString type, QString name, QString subType)
{
//qDebug() << "createComponent: " << "type: " << type << " desired name: " << name << " in system: " << this->getRootSystemName();
hopsan::Component *pCoreComponent = gHopsanCore.createComponent(type.toStdString().c_str());
Expand All @@ -710,6 +710,7 @@ QString CoreSystemAccess::createComponent(QString type, QString name)
{
pCoreComponent->setName(name.toStdString().c_str());
}
pCoreComponent->setSubTypeName(subType.toStdString().c_str());
//qDebug() << "createComponent: name after add: " << QString::fromStdString(pCoreComponent->getName()) << " added to: " << QString::fromStdString(mpCoreComponentSystem->getName());
return pCoreComponent->getName().c_str();
}
Expand Down
2 changes: 1 addition & 1 deletion HopsanGUI/CoreAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class CoreSystemAccess
QStringList getPortNames(const QString &componentName);

// Component creation and removal
QString createComponent(QString type, QString name="");
QString createComponent(QString type, QString name="", QString subType="");
QString createSubSystem(QString name="");
QString createConditionalSubSystem(QString name="");
void removeSubComponent(QString componentName, bool doDelete);
Expand Down
2 changes: 1 addition & 1 deletion HopsanGUI/GUIObjects/GUIComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Component::Component(QPointF position, double rotation, ModelObjectAppearance* p
: ModelObject(position, rotation, pAppearanceData, startSelected, gfxType, pParentSystem, pParentSystem)
{
// Create the object in core, and get its default core name
mName = mpParentSystemObject->getCoreSystemAccessPtr()->createComponent(mModelObjectAppearance.getTypeName(), mModelObjectAppearance.getDisplayName());
mName = mpParentSystemObject->getCoreSystemAccessPtr()->createComponent(mModelObjectAppearance.getTypeName(), mModelObjectAppearance.getDisplayName(), mModelObjectAppearance.getSubTypeName());
refreshDisplayName(); //Make sure name window is correct size for center positioning

// Sets the ports
Expand Down

0 comments on commit 9d29f3c

Please sign in to comment.