Skip to content

Commit

Permalink
- Some fixes for querying of components and inherited components.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24034 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Jan 14, 2015
1 parent bf86c82 commit b63d2f5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 42 deletions.
59 changes: 30 additions & 29 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -206,27 +206,29 @@ void Component::getClassInheritedComponents(bool isRootComponent, bool isPortCom
{
QString inheritedClass = mpOMCProxy->getNthInheritedClass(mClassName, i);
// avoid cycles
if (inheritedClass.compare(mClassName) == 0)
return;
// If the inherited class is one of the builtin type such as Real we can
// stop here, because the class can not contain any components, etc.
if (mpOMCProxy->isBuiltinType(inheritedClass))
return;
// get the inherited class annotation
StringHandler::ModelicaClasses type = mpOMCProxy->getClassRestriction(inheritedClass);
QString annotationString;
if (isLibraryComponent() || !isRootComponent)
annotationString = mpOMCProxy->getIconAnnotation(inheritedClass);
else if (type == StringHandler::Connector && mpGraphicsView->getViewType() == StringHandler::Diagram)
annotationString = mpOMCProxy->getDiagramAnnotation(inheritedClass);
else
annotationString = mpOMCProxy->getIconAnnotation(inheritedClass);
Component *pInheritedComponent;
pInheritedComponent = new Component(annotationString, inheritedClass, type, this);
/* if component is the port component and it has inherited components then stack its inherited components behind it. */
if (isPortComponent)
pInheritedComponent->setFlag(QGraphicsItem::ItemStacksBehindParent);
mInheritanceList.append(pInheritedComponent);
if (inheritedClass.compare(mClassName) != 0) {
// If the inherited class is one of the builtin type such as Real we can
// stop here, because the class can not contain any components, etc.
if (!mpOMCProxy->isBuiltinType(inheritedClass)) {
// get the inherited class annotation
StringHandler::ModelicaClasses type = mpOMCProxy->getClassRestriction(inheritedClass);
QString annotationString;
if (isLibraryComponent() || !isRootComponent) {
annotationString = mpOMCProxy->getIconAnnotation(inheritedClass);
} else if (type == StringHandler::Connector && mpGraphicsView->getViewType() == StringHandler::Diagram) {
annotationString = mpOMCProxy->getDiagramAnnotation(inheritedClass);
} else {
annotationString = mpOMCProxy->getIconAnnotation(inheritedClass);
}
Component *pInheritedComponent;
pInheritedComponent = new Component(annotationString, inheritedClass, type, this);
/* if component is the port component and it has inherited components then stack its inherited components behind it. */
if (isPortComponent) {
pInheritedComponent->setFlag(QGraphicsItem::ItemStacksBehindParent);
}
mInheritanceList.append(pInheritedComponent);
}
}
}
}

Expand Down Expand Up @@ -334,24 +336,23 @@ void Component::getClassComponents()
}
// get components
QList<ComponentInfo*> componentInfoList = mpOMCProxy->getComponents(mClassName);
if (componentInfoList.isEmpty())
if (componentInfoList.isEmpty()) {
return;
}
QStringList componentsAnnotations = mpOMCProxy->getComponentAnnotations(mClassName);
int i = 0;
foreach (ComponentInfo *pComponentInfo, componentInfoList)
{
foreach (ComponentInfo *pComponentInfo, componentInfoList) {
// just to be on safe-side.
if (componentsAnnotations.size() <= i)
if (componentsAnnotations.size() <= i) {
continue;
}
QString transformation = StringHandler::getPlacementAnnotation(componentsAnnotations.at(i));
// if component is protected we don't show it in the icon layer.
if (transformation.isEmpty() || pComponentInfo->getProtected() || mpOMCProxy->isBuiltinType(pComponentInfo->getClassName()))
{
if (transformation.isEmpty() || pComponentInfo->getProtected() || mpOMCProxy->isBuiltinType(pComponentInfo->getClassName())) {
i++;
continue;
}
if (mpOMCProxy->isWhat(StringHandler::Connector, pComponentInfo->getClassName()))
{
if (mpOMCProxy->isWhat(StringHandler::Connector, pComponentInfo->getClassName())) {
QString result = mpOMCProxy->getIconAnnotation(pComponentInfo->getClassName());
Component *pComponent = new Component(result, transformation, pComponentInfo, StringHandler::Connector,
getRootParentComponent());
Expand Down
23 changes: 10 additions & 13 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -2267,20 +2267,18 @@ void ModelWidget::getModelComponents(QString className, bool inheritedCycle)
stop here, because the class can not contain any components, etc.
Also check for cyclic loops.
*/
if (pMainWindow->getOMCProxy()->isBuiltinType(inheritedClass) || inheritedClass.compare(className) == 0)
return;
getModelComponents(inheritedClass, true);
if (!(pMainWindow->getOMCProxy()->isBuiltinType(inheritedClass) || inheritedClass.compare(className) == 0)) {
getModelComponents(inheritedClass, true);
}
}
// get the components
QList<ComponentInfo*> componentsList = pMainWindow->getOMCProxy()->getComponents(className);
// get the components annotations
QStringList componentsAnnotationsList = pMainWindow->getOMCProxy()->getComponentAnnotations(className);
int i = 0;
foreach (ComponentInfo *pComponentInfo, componentsList)
{
foreach (ComponentInfo *pComponentInfo, componentsList) {
/* if the component type is one of the builtin type then don't show it */
if (pMainWindow->getOMCProxy()->isBuiltinType(pComponentInfo->getClassName()))
{
if (pMainWindow->getOMCProxy()->isBuiltinType(pComponentInfo->getClassName())) {
i++;
continue;
}
Expand Down Expand Up @@ -2328,9 +2326,9 @@ void ModelWidget::getModelIconDiagramShapes(QString className, bool inheritedCyc
stop here, because the class can not contain any components, etc.
Also check for cyclic loops.
*/
if (pMainWindow->getOMCProxy()->isBuiltinType(inheritedClass) || inheritedClass.compare(className) == 0)
return;
getModelIconDiagramShapes(inheritedClass, true);
if (!(pMainWindow->getOMCProxy()->isBuiltinType(inheritedClass) || inheritedClass.compare(className) == 0)) {
getModelIconDiagramShapes(inheritedClass, true);
}
}
OMCProxy *pOMCProxy = mpModelWidgetContainer->getMainWindow()->getOMCProxy();
QString iconAnnotationString = pOMCProxy->getIconAnnotation(className);
Expand Down Expand Up @@ -2451,10 +2449,9 @@ void ModelWidget::getModelConnections(QString className, bool inheritedCycle)
stop here, because the class can not contain any components, etc.
Also check for cyclic loops.
*/
if (pMainWindow->getOMCProxy()->isBuiltinType(inheritedClass) || inheritedClass.compare(className) == 0) {
return;
if (!(pMainWindow->getOMCProxy()->isBuiltinType(inheritedClass) || inheritedClass.compare(className) == 0)) {
getModelConnections(inheritedClass, true);
}
getModelConnections(inheritedClass, true);
}
int connectionCount = pMainWindow->getOMCProxy()->getConnectionCount(className);
for (int i = 1 ; i <= connectionCount ; i++) {
Expand Down

0 comments on commit b63d2f5

Please sign in to comment.