Skip to content

Commit

Permalink
Fix for bug #1538 #1527 #1534
Browse files Browse the repository at this point in the history
- New getComponentAnnotations API is required to run OMEdit now.
- Updated the Model Browser to show the inherited components as well.
- Changed the open/save file dialog. Use the built-in static methods of QFileDialog because on Windows QFileDialog::exec has problems.
- Fixed some issues with connections. 
- Fixed the problem of protected parameters. Now the protected parameters are shown as disabled items. Also only the changed parameter will be updated instead of updating all parameters.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9528 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Jul 23, 2011
1 parent 5c72233 commit 68b2d75
Show file tree
Hide file tree
Showing 18 changed files with 750 additions and 1,010 deletions.
78 changes: 31 additions & 47 deletions OMEdit/OMEditGUI/Component.cpp
Expand Up @@ -78,9 +78,9 @@ Component::Component(QString value, QString name, QString className, QPointF pos
// if everything is fine with icon then add it to scene
mpGraphicsView->scene()->addItem(this);


if (mType == StringHandler::ICON && mIsConnector==true)
connect(this, SIGNAL(componentClicked(Component*)), mpGraphicsView, SLOT(addConnector(Component*)));
// if type is diagram then allow connections not for icon view
if (mType == StringHandler::ICON && mIsConnector)
connect(this, SIGNAL(componentClicked(Component*)), mpGraphicsView, SLOT(addConnector(Component*)));
}

/* Called for inheritance annotation instance */
Expand All @@ -102,7 +102,7 @@ Component::Component(QString value, QString className, int type, bool connector,
}

/* Called for component annotation instance */
Component::Component(QString value, QString transformationString,ComponentsProperties *pComponentProperties, int type,
Component::Component(QString value, QString transformationString, ComponentsProperties *pComponentProperties, int type,
bool connector, Component *pParent)
: ShapeAnnotation(pParent), mAnnotationString(value), mTransformationString(transformationString),
mpComponentProperties(pComponentProperties), mType(type), mIsConnector(connector)
Expand All @@ -126,16 +126,13 @@ Component::Component(QString value, QString transformationString,ComponentsPrope
getRootParentComponent()->mRectangle = mRectangle;

// if type is diagram then allow connections not for icon view
if (mpParentComponent->mType == StringHandler::ICON)
{

if (mType == StringHandler::ICON && mIsConnector)
connect(this, SIGNAL(componentClicked(Component*)), mpGraphicsView, SLOT(addConnector(Component*)));
}
}

/* Used for Library Component */
Component::Component(QString value, QString className, OMCProxy *omc, Component *pParent)
: ShapeAnnotation(pParent), mAnnotationString(value), mClassName(className), mpOMCProxy(omc)
Component::Component(QString value, QString className, bool connector, OMCProxy *omc, Component *pParent)
: ShapeAnnotation(pParent), mAnnotationString(value), mClassName(className), mIsConnector(connector), mpOMCProxy(omc)
{
mIsLibraryComponent = true;
mpParentComponent = pParent;
Expand All @@ -148,8 +145,8 @@ Component::Component(QString value, QString className, OMCProxy *omc, Component
}

/* Used for Library Component. Called for inheritance annotation instance */
Component::Component(QString value, QString className, Component *pParent)
: ShapeAnnotation(pParent), mAnnotationString(value), mClassName(className)
Component::Component(QString value, QString className, bool connector, Component *pParent)
: ShapeAnnotation(pParent), mAnnotationString(value), mClassName(className), mIsConnector(connector)
{
setFlag(QGraphicsItem::ItemStacksBehindParent);

Expand All @@ -158,7 +155,6 @@ Component::Component(QString value, QString className, Component *pParent)
mpOMCProxy = pParent->mpOMCProxy;
mpComponentProperties = 0;
mType = StringHandler::ICON;
mIsConnector = false;
parseAnnotationString(this, mAnnotationString, true);

//! @todo Since for some components we get empty annotations but its inherited componets does have annotations
Expand All @@ -168,18 +164,17 @@ Component::Component(QString value, QString className, Component *pParent)
}

/* Used for Library Component. Called for component annotation instance */
Component::Component(QString value, QString transformationString, ComponentsProperties *pComponentProperties,
Component::Component(QString value, QString transformationString, ComponentsProperties *pComponentProperties, bool connector,
Component *pParent)
: ShapeAnnotation(pParent), mAnnotationString(value), mTransformationString(transformationString),
mpComponentProperties(pComponentProperties)
mpComponentProperties(pComponentProperties), mIsConnector(connector)
{
mName = mpComponentProperties->getName();
mClassName = mpComponentProperties->getClassName();
mIsLibraryComponent = true;
mpParentComponent = pParent;
mpOMCProxy = pParent->mpOMCProxy;
mType = StringHandler::ICON;
mIsConnector = false;

parseAnnotationString(this, mAnnotationString, true);
mpTransformation = new Transformation(this);
Expand Down Expand Up @@ -371,7 +366,6 @@ bool Component::parseAnnotationString(Component *item, QString value, bool libra
item->mpShapesList.append(bitmapAnnotation);
}
}

}

QRectF Component::boundingRect() const
Expand Down Expand Up @@ -427,30 +421,17 @@ void Component::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,

void Component::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
MainWindow *pMainWindow =mpGraphicsView->mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow;

MainWindow *pMainWindow = mpGraphicsView->mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow;
// if user is viewing the component in Icon View
if ((mpGraphicsView->mIconType == StringHandler::ICON) or (mpGraphicsView->mpParentProjectTab->isReadOnly()))
return;

if(mIsConnector==true)
// if component is a connector type then emit the componentClicked signal
if (event->button() == Qt::LeftButton && pMainWindow->connectAction->isChecked() && mIsConnector)
{
// if(event->button()==Qt::LeftButton && !this->flags().testFlag((QGraphicsItem::ItemIsMovable)))
if(event->button()==Qt::LeftButton && pMainWindow->connectAction->isChecked())
{
emit componentClicked(this);

}
else
{

QGraphicsItem::mousePressEvent(event);
}

emit componentClicked(this);
}

else
{
// if we are creating the connector then make sure user can not select and move components
if ((mpGraphicsView->mIsCreatingConnector) and !mpParentComponent)
{
Expand All @@ -463,17 +444,11 @@ void Component::mousePressEvent(QGraphicsSceneMouseEvent *event)
setComponentFlags();
}

if (event->button() == Qt::LeftButton && pMainWindow->connectAction->isChecked())
{
emit componentClicked(this);
}

// call the mouse press event only if component is the root component
if (!mpParentComponent)
{
QGraphicsItem::mousePressEvent(event);
}
}
}

//! Event when mouse cursor enters component icon.
Expand Down Expand Up @@ -583,6 +558,8 @@ QVariant Component::itemChange(GraphicsItemChange change, const QVariant &value)
updateAnnotationString();
// update connectors annotations that are associated to this component
emit componentPositionChanged();
ProjectTab *pProjectTab = mpGraphicsView->mpParentProjectTab;
pProjectTab->mpModelicaEditor->setText(mpOMCProxy->list(pProjectTab->mModelNameStructure));
}
}
#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0))
Expand All @@ -591,6 +568,8 @@ QVariant Component::itemChange(GraphicsItemChange change, const QVariant &value)
emit componentRotated(true);
updateAnnotationString();
updateSelectionBox();
ProjectTab *pProjectTab = mpGraphicsView->mpParentProjectTab;
pProjectTab->mpModelicaEditor->setText(mpOMCProxy->list(pProjectTab->mModelNameStructure));
}
#endif
return value;
Expand Down Expand Up @@ -798,6 +777,9 @@ void Component::resizeComponent(qreal resizeFactorX, qreal resizeFactorY)
{
this->scale(resizeFactorX, resizeFactorY);
emit componentScaled();
updateAnnotationString();
ProjectTab *pProjectTab = mpGraphicsView->mpParentProjectTab;
pProjectTab->mpModelicaEditor->setText(mpOMCProxy->list(pProjectTab->mModelNameStructure));
}
}

Expand Down Expand Up @@ -847,12 +829,8 @@ clipboard->setText(this->getName());

//if(!clipboard->text().isEmpty())
//mpGraphicsView->mpPasteComponentAction->setDisabled(false);


}



void Component::openIconProperties()
{
IconProperties *iconProperties = new IconProperties(this, mpGraphicsView->mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow);
Expand Down Expand Up @@ -996,7 +974,7 @@ void Component::getClassComponents(QString className, int type)
// stop here, because the class can not contain any components, etc.
if(this->mpOMCProxy->isBuiltinType(inheritedClass))
{
mpInheritanceList.append(new Component("", inheritedClass, this));
mpInheritanceList.append(new Component("", inheritedClass, mpOMCProxy->isWhat(StringHandler::CONNECTOR, inheritedClass), this));
return;
}

Expand All @@ -1005,7 +983,7 @@ void Component::getClassComponents(QString className, int type)
Component *inheritance;
if (mIsLibraryComponent)
{
inheritance = new Component(annotationString, inheritedClass, this);
inheritance = new Component(annotationString, inheritedClass, mpOMCProxy->isWhat(StringHandler::CONNECTOR, inheritedClass), this);
}
else
{
Expand All @@ -1022,11 +1000,17 @@ void Component::getClassComponents(QString className, int type)
foreach (ComponentsProperties *componentProperties, components)
{
if (static_cast<QString>(componentsAnnotationsList.at(i)).toLower().contains("error"))
{
i++;
continue;
}

// if component is protected we don't show it in the icon layer.
if (componentProperties->getProtected())
{
i++;
continue;
}

if (StringHandler::removeFirstLastCurlBrackets(componentsAnnotationsList.at(i)).length() > 0)
{
Expand All @@ -1037,7 +1021,7 @@ void Component::getClassComponents(QString className, int type)
Component *component;
if (mIsLibraryComponent)
{
component = new Component(result, componentsAnnotationsList.at(i), componentProperties, this);
component = new Component(result, componentsAnnotationsList.at(i), componentProperties, true, this);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions OMEdit/OMEditGUI/Component.h
Expand Up @@ -89,9 +89,9 @@ class Component : public ShapeAnnotation
Component(QString value, QString transformationString, ComponentsProperties *pComponentProperties, int type,
bool connector, Component *pParent = 0);
/* Used for Library Component */
Component(QString value, QString className, OMCProxy *omc, Component *pParent = 0);
Component(QString value, QString className, Component *pParent = 0);
Component(QString value, QString transformationString, ComponentsProperties *pComponentProperties,
Component(QString value, QString className, bool connector, OMCProxy *omc, Component *pParent = 0);
Component(QString value, QString className, bool connector, Component *pParent = 0);
Component(QString value, QString transformationString, ComponentsProperties *pComponentProperties, bool connector,
Component *pParent = 0);
/* Used for Library Component */
/* Copy Constructors */
Expand Down

0 comments on commit 68b2d75

Please sign in to comment.