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

Store loaded subtypename in HopsanCore components #2195

Merged
merged 1 commit into from
Jan 23, 2024
Merged
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
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