Skip to content

Commit

Permalink
- OMEdit connector types updates.
Browse files Browse the repository at this point in the history
- Users guide updated with new features of OMEdit.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9635 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Aug 12, 2011
1 parent 8e82caa commit ed2cc61
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 88 deletions.
23 changes: 10 additions & 13 deletions OMEdit/OMEditGUI/Component.cpp
Expand Up @@ -564,25 +564,23 @@ QVariant Component::itemChange(GraphicsItemChange change, const QVariant &value)
// if user changes the position with mouse we handle it in mouse events of graphicsview
if (!isMousePressed)
{
/*if(mIsConnector)
if (mIsConnector)
{
Component *pComponent;
if (mpGraphicsView->mIconType == StringHandler::ICON)
{
pComponent = mpGraphicsView->mpParentProjectTab->mpDiagramGraphicsView->getComponentObject(getName());
pComponent->setPos(this->pos());
pComponent = mpGraphicsView->mpParentProjectTab->mpDiagramGraphicsView->getComponentObject(getName());
pComponent->setPos(this->pos());
}
else if(mpGraphicsView->mIconType == StringHandler::DIAGRAM)
{
//Component *pComponent;
pComponent = mpGraphicsView->mpParentProjectTab->mpIconGraphicsView->getComponentObject(getName());
pComponent->setPos(this->pos());
}
//if component is a connector, synchronize the position in its diagram view with the icon view
pComponent->updateAnnotationString();
}*/
}
updateAnnotationString();
// update connectors annotations that are associated to this component
emit componentPositionChanged();
Expand Down Expand Up @@ -796,7 +794,7 @@ void Component::updateAnnotationString(bool updateBothViews)
annotationString);

// call the addclassannotation if the graphicsview is icon, so the icon in the tree is also updated
if (mpGraphicsView->mIconType == StringHandler::ICON)
if (mpGraphicsView->mIconType == StringHandler::ICON || mIsConnector)
mpGraphicsView->addClassAnnotation();
}

Expand Down Expand Up @@ -1004,8 +1002,8 @@ 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, mpOMCProxy->isWhat(StringHandler::CONNECTOR, inheritedClass), this));
return;
mpInheritanceList.append(new Component("", inheritedClass, mpOMCProxy->isWhat(StringHandler::CONNECTOR, inheritedClass), this));
return;
}

QString annotationString = mpOMCProxy->getIconAnnotation(inheritedClass);
Expand All @@ -1017,13 +1015,12 @@ void Component::getClassComponents(QString className, int type)
}
else
{
inheritance = new Component(annotationString, inheritedClass, type,
mpOMCProxy->isWhat(StringHandler::CONNECTOR, inheritedClass), this);
inheritance = new Component(annotationString, inheritedClass, type, mpOMCProxy->isWhat(StringHandler::CONNECTOR, inheritedClass), this);
}
mpInheritanceList.append(inheritance);
getClassComponents(inheritedClass, type);
}
\

QList<ComponentsProperties*> components = mpOMCProxy->getComponents(className);
this->mpChildComponentProperties=components;
QStringList componentsAnnotationsList = mpOMCProxy->getComponentAnnotations(className);
Expand Down
28 changes: 5 additions & 23 deletions OMEdit/OMEditGUI/ConnectorWidget.cpp
Expand Up @@ -731,10 +731,8 @@ ConnectorArrayMenu::ConnectorArrayMenu(Connector *pConnector,QWidget *pParent)
mpStartIndexTextBox = new QLineEdit;
mpEndIndexLabel = new QLabel;
mpEndIndexTextBox = new QLineEdit;
mpStartMaxLabel= new QLabel;
mpEndMaxLabel= new QLabel;
mEndArrayExist=false;
mStartArrayExist=false;
mEndArrayExist = false;
mStartArrayExist = false;

// Create the buttons
mpOkButton = new QPushButton(tr("OK"));
Expand All @@ -753,12 +751,9 @@ ConnectorArrayMenu::ConnectorArrayMenu(Connector *pConnector,QWidget *pParent)
mainLayout->addWidget(mpLabel, 0, 0);
mainLayout->addWidget(mpStartIndexLabel, 1, 0);
mainLayout->addWidget(mpStartIndexTextBox, 2, 0);
mainLayout->addWidget(mpStartMaxLabel, 2, 0);
mainLayout->addWidget(mpEndIndexLabel, 3, 0);
mainLayout->addWidget(mpEndIndexTextBox, 4, 0);
mainLayout->addWidget(mpEndMaxLabel, 4, 0);

mainLayout->addWidget(mpButtonBox, 6, 0);
mainLayout->addWidget(mpButtonBox, 5, 0);

setLayout(mainLayout);
}
Expand Down Expand Up @@ -800,43 +795,30 @@ void ConnectorArrayMenu::show(int startMaxIndex, int endMaxIndex)
{
mpStartIndexLabel->setText(" Enter Index in the Array For Start Component :");
mpStartIndexTextBox->setText(tr(""));
if(startMaxIndex>0)
mpStartMaxLabel->setText("\t \t \tMaximum Index: " + QString ::number(startMaxIndex));
else
mpStartMaxLabel->setText("\t \t \tMaximum Index: No Bound");
mpStartIndexTextBox->setFocus();
mpStartIndexTextBox->setMaximumSize(QSize(100,20));
mStartArrayExist=true;
mStartArrayExist = true;
startIconCompName.append("[ i ]");
}
else
{
mpStartIndexLabel->hide();
mpStartIndexTextBox->hide();
mpStartMaxLabel->hide();
mpEndIndexTextBox->setFocus();
}
//if end port is a connector array
if(this->mpConnector->getEndConnectorisArray())
{
mpEndIndexLabel->setText(" Enter Index in the Array For End Component :");
mpEndIndexTextBox->setMaximumSize(QSize(100,20));
mpEndIndexTextBox->setText(tr(""));
if(endMaxIndex>0)
mpEndMaxLabel->setText("\t \t \tMaximum Index: " + QString ::number(endMaxIndex));
else
mpEndMaxLabel->setText("\t \t \tMaximum Index: No Bound");
mEndArrayExist=true;
mEndArrayExist = true;
endIconCompName.append("[ j ]");
}
else
{
mpEndIndexLabel->hide();
mpEndIndexTextBox->hide();
mpEndMaxLabel->hide();
}


mpLabel->setText("CONNECT " + startIconName+startIconCompName + " WITH "+ endIconName + endIconCompName);
mStartMaxIndex=startMaxIndex;
mEndMaxIndex=endMaxIndex;
Expand Down
2 changes: 0 additions & 2 deletions OMEdit/OMEditGUI/ConnectorWidget.h
Expand Up @@ -161,8 +161,6 @@ void show(int startMaxIndex, int endMaxIndex);
QLabel *mpLabel;
QLabel *mpStartIndexLabel;
QLabel *mpEndIndexLabel;
QLabel *mpStartMaxLabel;
QLabel *mpEndMaxLabel;
QString mEndConnectorIndex;
QString mStartConnectorIndex;

Expand Down
5 changes: 4 additions & 1 deletion OMEdit/OMEditGUI/DocumentationWidget.cpp
Expand Up @@ -117,7 +117,10 @@ void DocumentationWidget::showDocumentationEditView(QString className)
mpDocumentationViewer->hide();
// get the already existing documentation text of the model
mpDocumentationEditor->toPlainText();
mpDocumentationEditor->setPlainText(mpParentMainWindow->mpOMCProxy->getDocumentationAnnotation(className));
if (!mpParentMainWindow->mpOMCProxy->getDocumentationAnnotation(className).isEmpty())
mpDocumentationEditor->setPlainText(mpParentMainWindow->mpOMCProxy->getDocumentationAnnotation(className));
else
mpDocumentationEditor->setPlainText("<html>\n\n</html>");
mpDocumentationEditor->setFocus();
mpDocumentationEditor->show();
}
Expand Down
65 changes: 34 additions & 31 deletions OMEdit/OMEditGUI/ProjectTabWidget.cpp
Expand Up @@ -234,8 +234,9 @@ void GraphicsView::dropEvent(QDropEvent *event)
{
if (type == StringHandler::CONNECTOR)
{
addComponentoView(name, classname, point, true, true, true);
mpParentProjectTab->mpIconGraphicsView->addComponentoView(name, classname, point, true, false);
addComponentoView(name, classname, point, true, true, true);
mpParentProjectTab->mpIconGraphicsView->addClassAnnotation();
}
else
{
Expand All @@ -259,8 +260,8 @@ void GraphicsView::dropEvent(QDropEvent *event)
if (type == StringHandler::CONNECTOR)
{
addComponentoView(name, classname, point, true, false);
mpParentProjectTab->mpDiagramGraphicsView->addComponentoView(name, classname, point, true,
true, true);
mpParentProjectTab->mpDiagramGraphicsView->addComponentoView(name, classname, point, true, true, true);
addClassAnnotation();
event->accept();
emit currentChange(1);
}
Expand Down Expand Up @@ -324,10 +325,12 @@ void GraphicsView::addComponentObject(Component *component)
{
MainWindow *pMainWindow = mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow;
// Add the component to model in OMC Global Scope.
pMainWindow->mpOMCProxy->addComponent(component->getName(), component->getClassName(),
mpParentProjectTab->mModelNameStructure);
pMainWindow->mpOMCProxy->addComponent(component->getName(), component->getClassName(), mpParentProjectTab->mModelNameStructure);
// add the annotations of icon
component->updateAnnotationString(false);
if (component->getIsConnector())
component->updateAnnotationString(true);
else
component->updateAnnotationString(false);
// only update the modelicatext of model if its a diagram view
// for icon view the modeltext is updated in updateannotationstring->addclassannotation
if (mIconType == StringHandler::DIAGRAM)
Expand Down Expand Up @@ -376,10 +379,11 @@ void GraphicsView::deleteComponentObject(Component *component, bool update)
//! @see deleteComponentObject(Component *component, bool update)
void GraphicsView::deleteAllComponentObjects()
{
foreach (Component *component, mComponentsList)
{
component->deleteMe(false);
}
mComponentsList.clear();
// foreach (Component *component, mComponentsList)
// {
// component->deleteMe(false);
// }
}

Component* GraphicsView::getComponentObject(QString componentName)
Expand Down Expand Up @@ -433,20 +437,22 @@ void GraphicsView::deleteShapeObject(ShapeAnnotation *shape)

void GraphicsView::deleteAllShapesObject()
{
foreach (ShapeAnnotation *shape, mShapesList)
{
shape->deleteMe();
}
mShapesList.clear();
// foreach (ShapeAnnotation *shape, mShapesList)
// {
// shape->deleteMe();
// }
}

void GraphicsView::removeAllConnectors()
{
int i = 0;
while(i != mConnectorsVector.size())
{
this->removeConnector(mConnectorsVector[i], false);
i = 0; //Restart iteration if map has changed
}
mConnectorsVector.clear();
// int i = 0;
// while(i != mConnectorsVector.size())
// {
// this->removeConnector(mConnectorsVector[i], false);
// i = 0; //Restart iteration if map has changed
// }
}

//! Defines what happens when the mouse is moving in a GraphicsView.
Expand Down Expand Up @@ -585,28 +591,23 @@ void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
{
if (component->mOldPosition != component->pos())
{
/*if(component->getIsConnector())
if(component->getIsConnector())
{
Component *pComponent;
if (mIconType == StringHandler::ICON)
{
pComponent = mpParentProjectTab->mpDiagramGraphicsView->getComponentObject(component->getName());
pComponent->setPos(component->pos());
pComponent = mpParentProjectTab->mpDiagramGraphicsView->getComponentObject(component->getName());
pComponent->setPos(component->pos());
}
else if(mIconType == StringHandler::DIAGRAM)
{
// Component *pComponent;
pComponent = mpParentProjectTab->mpIconGraphicsView->getComponentObject(component->getName());
pComponent->setPos(component->pos());
}
pComponent->updateAnnotationString();

}*/
}
component->updateAnnotationString();

// if there are any connectors associated to component update their annotations as well.
foreach (Connector *connector, mConnectorsVector)
{
Expand Down Expand Up @@ -2444,18 +2445,20 @@ bool ProjectTab::modelicaEditorTextChanged()
pTree->deleteNodeTriggered(pTree->getNode(modelNameStructure), false);
// if the modelicatext is fine then do the processing on the list of models we get
mpParentProjectTabWidget->mpParentMainWindow->mpLibrary->loadModel(mpModelicaEditor->toPlainText(), models);
QString modelsText = mpModelicaEditor->toPlainText();
//QString modelsText = mpModelicaEditor->toPlainText();
// now update the current opened tab
mModelNameStructure = models.first();
updateTabName(StringHandler::getLastWordAfterDot(mModelNameStructure), mModelNameStructure);
// clear the complete view before loading the models again
mpIconGraphicsView->removeAllConnectors();
mpIconGraphicsView->deleteAllComponentObjects();
mpIconGraphicsView->deleteAllShapesObject();
mpIconGraphicsView->scene()->clear();
mpDiagramGraphicsView->removeAllConnectors();
mpDiagramGraphicsView->deleteAllComponentObjects();
mpDiagramGraphicsView->deleteAllShapesObject();
mpParentProjectTabWidget->mpParentMainWindow->mpOMCProxy->loadString(modelsText);
mpDiagramGraphicsView->scene()->clear();
//mpParentProjectTabWidget->mpParentMainWindow->mpOMCProxy->loadString(modelsText);
// get the model components and connectors now
getModelComponents();
getModelConnections();
Expand Down

0 comments on commit ed2cc61

Please sign in to comment.