Skip to content

Commit

Permalink
->Combined the Connector Array Menu for both the start and the end port.
Browse files Browse the repository at this point in the history
->some commenting and removal of unnecessary code

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9561 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
abhinn kothari committed Jul 30, 2011
1 parent a0d68bd commit f91c010
Show file tree
Hide file tree
Showing 15 changed files with 493 additions and 727 deletions.
43 changes: 39 additions & 4 deletions OMEdit/OMEditGUI/Component.cpp
Expand Up @@ -87,6 +87,7 @@ Component::Component(QString value, QString name, QString className, QPointF pos
Component::Component(QString value, QString className, int type, bool connector, Component *pParent)
: ShapeAnnotation(pParent), mAnnotationString(value), mClassName(className), mType(type), mIsConnector(connector)
{

setFlag(QGraphicsItem::ItemStacksBehindParent);
mIsLibraryComponent = false;
mpParentComponent = pParent;
Expand All @@ -95,6 +96,8 @@ Component::Component(QString value, QString className, int type, bool connector,
mpComponentProperties = 0;
parseAnnotationString(this, mAnnotationString);

//this->mpChildComponentProperties = mpOMCProxy->getComponents(this->mClassName);

//! @todo Since for some components we get empty annotations but its inherited componets does have annotations
//! @todo so set the parent give the parent bounding box the value of inherited class boundingbox.
if (mRectangle.width() > 1)
Expand All @@ -109,6 +112,7 @@ Component::Component(QString value, QString transformationString, ComponentsProp
{
mName = mpComponentProperties->getName();
mClassName = mpComponentProperties->getClassName();

mIsLibraryComponent = false;
mpParentComponent = pParent;
mpOMCProxy = pParent->mpOMCProxy;
Expand All @@ -119,7 +123,7 @@ Component::Component(QString value, QString transformationString, ComponentsProp

mpTransformation = new Transformation(this);
setTransform(mpTransformation->getTransformationMatrix());

//this->mpChildComponentProperties = mpOMCProxy->getComponents(this->mClassName);
//! @todo Since for some components we get empty annotations but its inherited componets does have annotations
//! @todo so set the parent give the parent bounding box the value of inherited class boundingbox.
if (mRectangle.width() > 1)
Expand All @@ -142,6 +146,7 @@ Component::Component(QString value, QString className, bool connector, OMCProxy

parseAnnotationString(this, value, true);
getClassComponents(mClassName, mType);

}

/* Used for Library Component. Called for inheritance annotation instance */
Expand All @@ -156,6 +161,7 @@ Component::Component(QString value, QString className, bool connector, Component
mpComponentProperties = 0;
mType = StringHandler::ICON;
parseAnnotationString(this, mAnnotationString, true);
//this->mpChildComponentProperties = mpOMCProxy->getComponents(this->mClassName);

//! @todo Since for some components we get empty annotations but its inherited componets does have annotations
//! @todo so set the parent give the parent bounding box the value of inherited class boundingbox.
Expand All @@ -177,6 +183,7 @@ Component::Component(QString value, QString transformationString, ComponentsProp
mType = StringHandler::ICON;

parseAnnotationString(this, mAnnotationString, true);
//this->mpChildComponentProperties = mpOMCProxy->getComponents(this->mClassName);
mpTransformation = new Transformation(this);
setTransform(mpTransformation->getTransformationMatrix());

Expand All @@ -202,6 +209,8 @@ Component::Component(Component *pComponent, QString name, QPointF position, int
mIconParametersList.append(mpOMCProxy->getParameters(mpGraphicsView->mpParentProjectTab->mModelNameStructure,
mClassName, mName));
parseAnnotationString(this, mAnnotationString);

this->mpChildComponentProperties = mpOMCProxy->getComponents(this->mClassName);
// if component is an icon
if ((mType == StringHandler::ICON))
{
Expand Down Expand Up @@ -555,6 +564,25 @@ 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)
{
Component *pComponent;
if (mpGraphicsView->mIconType == StringHandler::ICON)
{
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());
}
pComponent->updateAnnotationString();
}*/
updateAnnotationString();
// update connectors annotations that are associated to this component
emit componentPositionChanged();
Expand Down Expand Up @@ -736,6 +764,7 @@ void Component::updateAnnotationString(bool updateBothViews)
}
if (mIsConnector and updateBothViews)
{

if (mpGraphicsView->mIconType == StringHandler::ICON)
{
// first get the component from diagram view and get the transformations
Expand Down Expand Up @@ -800,6 +829,9 @@ void Component::deleteMe(bool update)
delete(this);
}


//copying a component or a selected scene, currently non functional,just works for a single
//component, to do
void Component::copyComponent()
{
GraphicsView *pGraphicsView = qobject_cast<GraphicsView*>(const_cast<QObject*>(sender()));
Expand Down Expand Up @@ -834,7 +866,7 @@ void Component::openIconProperties()
IconProperties *iconProperties = new IconProperties(this, mpGraphicsView->mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow);
iconProperties->show();
}

//to change from non connecting mode to conecting mode for a connector or vice versa.
void Component::changeConnectMode()
{
if(!this->flags().testFlag((QGraphicsItem::ItemIsMovable)))
Expand Down Expand Up @@ -991,8 +1023,9 @@ void Component::getClassComponents(QString className, int type)
mpInheritanceList.append(inheritance);
getClassComponents(inheritedClass, type);
}

\
QList<ComponentsProperties*> components = mpOMCProxy->getComponents(className);
this->mpChildComponentProperties=components;
QStringList componentsAnnotationsList = mpOMCProxy->getComponentAnnotations(className);
int i = 0;
foreach (ComponentsProperties *componentProperties, components)
Expand Down Expand Up @@ -1082,6 +1115,8 @@ void Component::getClassComponents(QString className, int type, Component *pPare
}

QList<ComponentsProperties*> components = mpOMCProxy->getComponents(className);
this->mpChildComponentProperties=components;

QStringList componentsAnnotationsList = mpOMCProxy->getComponentAnnotations(className);
int i = 0;
foreach (ComponentsProperties *componentProperties, components)
Expand Down Expand Up @@ -1139,7 +1174,7 @@ void Component::getClassComponents(QString className, int type, Component *pPare

//! this function is called when we need to create a copy of one component
void Component::copyClassComponents(Component *pComponent)
{
{
foreach(Component *inheritance, pComponent->mpInheritanceList)
{
Component *inheritanceComponent = new Component(inheritance->mAnnotationString, inheritance->mClassName,
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Component.h
Expand Up @@ -110,6 +110,7 @@ class Component : public ShapeAnnotation
OMCProxy *mpOMCProxy;
GraphicsView *mpGraphicsView;
ComponentsProperties *mpComponentProperties;
QList<ComponentsProperties*> mpChildComponentProperties;
Transformation *mpTransformation;
QList<ShapeAnnotation*> mpShapesList;
QList<Component*> mpInheritanceList;
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/ComponentsProperties.cpp
Expand Up @@ -68,7 +68,7 @@ void ComponentsProperties::parseString(QString value)
{
if (value.isEmpty())
return;

// retrieving the index value in case the connecting port is an array type
int index = 0;
QStringList list = StringHandler::getStrings(value);
mIndex = StringHandler::removeFirstLastCurlBrackets(list.at(list.size()-1));
Expand Down

0 comments on commit f91c010

Please sign in to comment.