Skip to content

Commit

Permalink
Draw and allow connection from Expandable Connector.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Oct 14, 2015
1 parent 52537d5 commit 797bbe7
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 20 deletions.
8 changes: 4 additions & 4 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -670,8 +670,8 @@ void ShapeAnnotation::drawCornerItems()
*/
void ShapeAnnotation::setCornerItemsActive()
{
foreach (CornerItem *pCornerItem, mCornerItemsList)
{
foreach (CornerItem *pCornerItem, mCornerItemsList) {
pCornerItem->setToolTip(Helper::clickAndDragToResize);
pCornerItem->setVisible(true);
}
}
Expand All @@ -681,8 +681,8 @@ void ShapeAnnotation::setCornerItemsActive()
*/
void ShapeAnnotation::setCornerItemsPassive()
{
foreach (CornerItem *pCornerItem, mCornerItemsList)
{
foreach (CornerItem *pCornerItem, mCornerItemsList) {
pCornerItem->setToolTip("");
pCornerItem->setVisible(false);
}
}
Expand Down
8 changes: 4 additions & 4 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -387,7 +387,7 @@ void Component::createClassInheritedShapes()
void Component::createClassShapes(LibraryTreeItem *pLibraryTreeItem)
{
GraphicsView *pGraphicsView = pLibraryTreeItem->getModelWidget()->getIconGraphicsView();
if (pLibraryTreeItem->getRestriction() == StringHandler::Connector && mpGraphicsView->getViewType() == StringHandler::Diagram &&
if (pLibraryTreeItem->isConnector() && mpGraphicsView->getViewType() == StringHandler::Diagram &&
mComponentType == Component::Root && pLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->hasAnnotation()) {
pGraphicsView = pLibraryTreeItem->getModelWidget()->getDiagramGraphicsView();
}
Expand Down Expand Up @@ -677,7 +677,7 @@ QString Component::getPlacementAnnotation()
if (mTransformation.isValid()) {
placementAnnotationString.append("visible=").append(mTransformation.getVisible() ? "true" : "false");
}
if (mpLibraryTreeItem && mpLibraryTreeItem->getRestriction() == StringHandler::Connector) {
if (mpLibraryTreeItem && mpLibraryTreeItem->isConnector()) {
if (mpGraphicsView->getViewType() == StringHandler::Icon) {
// first get the component from diagram view and get the transformations
Component *pComponent;
Expand Down Expand Up @@ -860,7 +860,7 @@ void Component::shapeDeleted()
{
if (mComponentType == Component::Root) {
GraphicsView *pGraphicsView = mpLibraryTreeItem->getModelWidget()->getIconGraphicsView();
if (mpLibraryTreeItem->getRestriction() == StringHandler::Connector && mpGraphicsView->getViewType() == StringHandler::Diagram &&
if (mpLibraryTreeItem->isConnector() && mpGraphicsView->getViewType() == StringHandler::Diagram &&
mComponentType == Component::Root && mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView()->hasAnnotation()) {
pGraphicsView = mpLibraryTreeItem->getModelWidget()->getDiagramGraphicsView();
}
Expand Down Expand Up @@ -1215,7 +1215,7 @@ void Component::duplicate()
QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
if (mpGraphicsView->addComponent(mpLibraryTreeItem->getNameStructure(), scenePos() + gridStep)) {
if (mpLibraryTreeItem->getRestriction() == StringHandler::Connector) {
if (mpLibraryTreeItem->isConnector()) {
if (mpGraphicsView->getViewType() == StringHandler::Diagram) {
duplicateHelper(mpGraphicsView);
duplicateHelper(mpGraphicsView->getModelWidget()->getIconGraphicsView());
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Component/CornerItem.cpp
Expand Up @@ -233,6 +233,7 @@ void ResizerItem::setActive()
} else {
mPen = mActivePen;
}
setToolTip(Helper::clickAndDragToResize);
setVisible(true);
}

Expand All @@ -243,6 +244,7 @@ void ResizerItem::setActive()
void ResizerItem::setPassive()
{
mPen = mPassivePen;
setToolTip("");
setVisible(false);
}

Expand Down
10 changes: 5 additions & 5 deletions OMEdit/OMEditGUI/Modeling/Commands.cpp
Expand Up @@ -199,7 +199,7 @@ AddComponentCommand::AddComponentCommand(QString name, LibraryTreeItem *pLibrary

ModelWidget *pModelWidget = mpGraphicsView->getModelWidget();
// if component is of connector type && containing class is Modelica type.
if (mpLibraryTreeItem && mpLibraryTreeItem->getRestriction() == StringHandler::Connector &&
if (mpLibraryTreeItem && mpLibraryTreeItem->isConnector() &&
pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) {
// first create the component for Icon View
mpIconComponent = new Component(name, pLibraryTreeItem, transformationString, position, pComponentInfo, mpIconGraphicsView);
Expand Down Expand Up @@ -232,7 +232,7 @@ void AddComponentCommand::redo()
{
ModelWidget *pModelWidget = mpGraphicsView->getModelWidget();
// if component is of connector type && containing class is Modelica type.
if (mpLibraryTreeItem && mpLibraryTreeItem->getRestriction() == StringHandler::Connector &&
if (mpLibraryTreeItem && mpLibraryTreeItem->isConnector() &&
pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) {
// first create the component for Icon View only if connector is not protected
if (!mpComponentInfo->getProtected()) {
Expand Down Expand Up @@ -265,7 +265,7 @@ void AddComponentCommand::undo()
{
ModelWidget *pModelWidget = mpGraphicsView->getModelWidget();
// if component is of connector type && containing class is Modelica type.
if (mpLibraryTreeItem && mpLibraryTreeItem->getRestriction() == StringHandler::Connector &&
if (mpLibraryTreeItem && mpLibraryTreeItem->isConnector() &&
pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) {
// first create the component for Icon View only if connector is not protected
if (!mpComponentInfo->getProtected()) {
Expand Down Expand Up @@ -358,7 +358,7 @@ void DeleteComponentCommand::redo()
{
ModelWidget *pModelWidget = mpGraphicsView->getModelWidget();
// if component is of connector type && containing class is Modelica type.
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->getRestriction() == StringHandler::Connector &&
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->isConnector() &&
pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) {
// first remove the component from Icon View
mpIconComponent = mpIconGraphicsView->getComponentObject(mpComponent->getName());
Expand Down Expand Up @@ -396,7 +396,7 @@ void DeleteComponentCommand::undo()
{
ModelWidget *pModelWidget = mpGraphicsView->getModelWidget();
// if component is of connector type && containing class is Modelica type.
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->getRestriction() == StringHandler::Connector &&
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->isConnector() &&
pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) {
// first add the component to Icon View
if (mpIconComponent) {
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -421,6 +421,7 @@ QIcon LibraryTreeItem::getLibraryTreeItemIcon()
case StringHandler::Class:
return QIcon(":/Resources/icons/class-icon.svg");
case StringHandler::Connector:
case StringHandler::ExpandableConnector:
return QIcon(":/Resources/icons/connect-mode.svg");
case StringHandler::Record:
return QIcon(":/Resources/icons/record-icon.svg");
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.h
Expand Up @@ -111,6 +111,7 @@ class LibraryTreeItem : public QObject
void setIsDocumentationClass(bool documentationClass) {mDocumentationClass = documentationClass;}
bool isDocumentationClass() {return mDocumentationClass;}
StringHandler::ModelicaClasses getRestriction() {return StringHandler::getModelicaClassType(mClassInformation.restriction);}
bool isConnector() {return (getRestriction() == StringHandler::ExpandableConnector || getRestriction() == StringHandler::Connector);}
bool isPartial() {return mClassInformation.partialPrefix;}
void setSaveContentsType(LibraryTreeItem::SaveContentsType saveContentsType) {mSaveContentsType = saveContentsType;}
SaveContentsType getSaveContentsType() {return mSaveContentsType;}
Expand Down
8 changes: 4 additions & 4 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -325,7 +325,7 @@ bool GraphicsView::addComponent(QString className, QPointF position)
if (mViewType == StringHandler::Diagram) {
// if item is a class, model, block, connector or record. then we can drop it to the graphicsview
if ((type == StringHandler::Class) || (type == StringHandler::Model) || (type == StringHandler::Block) ||
(type == StringHandler::Connector) || (type == StringHandler::Record)) {
(type == StringHandler::ExpandableConnector) || (type == StringHandler::Connector) || (type == StringHandler::Record)) {
addComponentToView(name, pLibraryTreeItem, "", position, new ComponentInfo(""));
return true;
} else {
Expand All @@ -336,7 +336,7 @@ bool GraphicsView::addComponent(QString className, QPointF position)
}
} else if (mViewType == StringHandler::Icon) { // if dropping an item on the icon layer
// if item is a connector. then we can drop it to the graphicsview
if (type == StringHandler::Connector) {
if (type == StringHandler::Connector || type == StringHandler::ExpandableConnector) {
addComponentToView(name, pLibraryTreeItem, "", position, new ComponentInfo(""));
return true;
} else {
Expand Down Expand Up @@ -1491,7 +1491,7 @@ void GraphicsView::mousePressEvent(QMouseEvent *event)
Component *pComponent = dynamic_cast<Component*>(pGraphicsItem->parentItem());
if (pComponent && !pComponent->isSelected()) {
if (pMainWindow->getConnectModeAction()->isChecked() && mViewType == StringHandler::Diagram &&
pComponent->getLibraryTreeItem() && pComponent->getLibraryTreeItem()->getRestriction() == StringHandler::Connector &&
pComponent->getLibraryTreeItem() && pComponent->getLibraryTreeItem()->isConnector() &&
!mpModelWidget->getLibraryTreeItem()->isSystemLibrary()) {
if (!isCreatingConnection()) {
mpClickedComponent = pComponent;
Expand Down Expand Up @@ -1528,7 +1528,7 @@ void GraphicsView::mouseMoveEvent(QMouseEvent *event)
Component *pComponent = dynamic_cast<Component*>(pGraphicsItem->parentItem());
if (pComponent && !pComponent->isSelected()) {
if (pMainWindow->getConnectModeAction()->isChecked() && mViewType == StringHandler::Diagram &&
pComponent->getLibraryTreeItem() && pComponent->getLibraryTreeItem()->getRestriction() == StringHandler::Connector &&
pComponent->getLibraryTreeItem() && pComponent->getLibraryTreeItem()->isConnector() &&
!mpModelWidget->getLibraryTreeItem()->isSystemLibrary()) {
setCrossCursor = true;
/* If setOverrideCursor() has been called twice, calling restoreOverrideCursor() will activate the first cursor set.
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/Util/StringHandler.cpp
Expand Up @@ -72,10 +72,10 @@ QString StringHandler::getModelicaClassType(int type)
return "Model";
case StringHandler::Class:
return "Class";
case StringHandler::Connector:
return "Connector";
case StringHandler::ExpandableConnector:
return "Expandable Connector";
case StringHandler::Connector:
return "Connector";
case StringHandler::Record:
return "Record";
case StringHandler::Block:
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Util/StringHandler.h
Expand Up @@ -55,7 +55,7 @@ class StringHandler : public QObject
StringHandler();
~StringHandler();
enum ViewType {Icon, Diagram, ModelicaText, NoView};
enum ModelicaClasses {Model, Class, Connector, ExpandableConnector, Record, Block, Function, Package, Primitive, Type, Operator,
enum ModelicaClasses {Model, Class, ExpandableConnector, Connector, Record, Block, Function, Package, Primitive, Type, Operator,
OperatorRecord, OperatorFunction, Optimization, Parameter, Constant, Protected, Enumeration};
enum OpenModelicaErrors {Notification, Warning, OMError, NoOMError};
enum OpenModelicaErrorKinds {Syntax, Grammar, Translation, Symbolic, Simulation, Scripting, NoOMErrorKind};
Expand Down

0 comments on commit 797bbe7

Please sign in to comment.