Skip to content

Commit

Permalink
- Some updates in OMEdit icon editor.
Browse files Browse the repository at this point in the history
- OMEdit now uses new integrated plotting.
- changed the OMPlot tool so that it uses setRawdata (finally).
- New function to get color for plot curves. for 10 curves it uses the predefined colors for curves more than 10 it uses the hsv scale.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8491 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 5, 2011
1 parent 73eda73 commit d05837c
Show file tree
Hide file tree
Showing 61 changed files with 2,996 additions and 428 deletions.
2 changes: 1 addition & 1 deletion OMEdit/INSTALL.txt
Expand Up @@ -4,7 +4,7 @@
Windows
------------------------------

OMEdit uses Qt 4.7.0
OMEdit uses Qt 4.7.0
------------------------------
- Download the Qt SDK for windows from http://qt.nokia.com/downloads. The SDK also contains the Qt Creator.

Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/BitmapAnnotation.cpp
Expand Up @@ -84,6 +84,7 @@ void BitmapAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *
Q_UNUSED(option);
Q_UNUSED(widget);

setTransformOriginPoint(boundingRect().center());
if(!mImageSource.isEmpty())
{
//open file from image source
Expand Down
20 changes: 11 additions & 9 deletions OMEdit/OMEditGUI/Component.cpp
Expand Up @@ -70,7 +70,6 @@ Component::Component(QString value, QString name, QString className, QPointF pos
setPos(position);
getClassComponents(mClassName, mType, this);
}

// if everything is fine with icon then add it to scene
mpGraphicsView->scene()->addItem(this);
}
Expand Down Expand Up @@ -222,7 +221,6 @@ Component::Component(Component *pComponent, QString name, QPointF position, int
setPos(position);
copyClassComponents(pComponent);
}

// if everything is fine with icon then add it to scene
mpGraphicsView->scene()->addItem(this);
}
Expand Down Expand Up @@ -673,20 +671,20 @@ QString Component::getTransformationString()
annotationString.append("{").append(QString::number(extent2.x())).append(",");
annotationString.append(QString::number(extent2.y())).append("}}, ");
// add icon rotation
annotationString.append("rotation=").append(QString::number(rotation())).append("))");
annotationString.append("rotation=").append(QString::number(rotation())).append(")");

return annotationString;
}

void Component::updateAnnotationString()
void Component::updateAnnotationString(bool updateBothViews)
{
// create the annotation string
QString annotationString = "annotate=Placement(";
if (mpOMCProxy->mAnnotationVersion == OMCProxy::ANNOTATION_VERSION3X)
{
annotationString.append("visible=true, ");
}
if (mIsConnector)
if (mIsConnector and updateBothViews)
{
if (mpGraphicsView->mIconType == StringHandler::ICON)
{
Expand All @@ -713,6 +711,7 @@ void Component::updateAnnotationString()
{
annotationString.append(getTransformationString());
}
annotationString.append(")");
// Add component annotation.
mpOMCProxy->updateComponent(mName, mClassName, mpGraphicsView->mpParentProjectTab->mModelNameStructure,
annotationString);
Expand All @@ -734,14 +733,17 @@ void Component::resizeComponent(qreal resizeFactorX, qreal resizeFactorY)
//! Tells the component to ask its parent to delete it.
void Component::deleteMe()
{
GraphicsView *pGraphicsView = qobject_cast<GraphicsView*>(const_cast<QObject*>(sender()));
// delete the component from model
mpGraphicsView->deleteComponentObject(this);
// remove the component from the scene
mpGraphicsView->scene()->removeItem(this);
// call the addclassannotation if the graphicsview is diagram, so the icon in the tree is also updated
if (mpGraphicsView->mIconType == StringHandler::ICON)
mpGraphicsView->addClassAnnotation();
// delete the component instance
// if the signal is not send by graphicsview then call addclassannotation
if (!pGraphicsView)
{
if (mpGraphicsView->mIconType == StringHandler::ICON)
mpGraphicsView->addClassAnnotation();
}
delete(this);
}

Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Component.h
Expand Up @@ -148,7 +148,7 @@ class Component : public ShapeAnnotation
void componentRotated(bool isRotated);
void componentScaled();
public slots:
void updateAnnotationString();
void updateAnnotationString(bool updateBothViews = true);
void showSelectionBox();
void resizeComponent(qreal resizeFactorX, qreal resizeFactorY);
void deleteMe();
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/EllipseAnnotation.cpp
Expand Up @@ -78,6 +78,7 @@ void EllipseAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem
Q_UNUSED(option);
Q_UNUSED(widget);

setTransformOriginPoint(boundingRect().center());
drawEllipseAnnotaion(painter);
}

Expand Down
57 changes: 54 additions & 3 deletions OMEdit/OMEditGUI/Helper.cpp
Expand Up @@ -84,6 +84,53 @@ QString Helper::omi_pause_button_tooltip = QString("Pauses the running interacti
QString Helper::omi_stop_button_tooltip = QString("Stops the running interactive simulation and resets all values to the beginning.");
QString Helper::omi_shutdown_button_tooltip = QString("Shut down the running interactive simulation.");
QString Helper::omi_showlog_button_tooltip = QString("Shows the OMI Log Message Window.");
// pen styles with icons
QString Helper::solidPenIcon = QString(":/Resources/icons/solidline.png");
QString Helper::solidPen = QString("Solid");
Qt::PenStyle Helper::solidPenStyle = Qt::SolidLine;
QString Helper::dashPenIcon = QString(":/Resources/icons/dashline.png");
QString Helper::dashPen = QString("Dash");
Qt::PenStyle Helper::dashPenStyle = Qt::DashLine;
QString Helper::dotPenIcon = QString(":/Resources/icons/dotline.png");
QString Helper::dotPen = QString("Dot");
Qt::PenStyle Helper::dotPenStyle = Qt::DotLine;
QString Helper::dashDotPenIcon = QString(":/Resources/icons/dashdotline.png");
QString Helper::dashDotPen = QString("Dash Dot");
Qt::PenStyle Helper::dashDotPenStyle = Qt::DashDotLine;
QString Helper::dashDotDotPenIcon = QString(":/Resources/icons/dashdotdotline.png");
QString Helper::dashDotDotPen = QString("Dash Dot Dot");
Qt::PenStyle Helper::dashDotDotPenStyle = Qt::DashDotDotLine;
// brush styles with icons
QString Helper::solidBrushIcon = QString(":/Resources/icons/solid.png");
QString Helper::solidBrush = QString("Solid");
Qt::BrushStyle Helper::solidBrushStyle = Qt::SolidPattern;
QString Helper::horizontalBrushIcon = QString(":/Resources/icons/horizontal.png");
QString Helper::horizontalBrush = QString("Horizontal");
Qt::BrushStyle Helper::horizontalBrushStyle = Qt::HorPattern;
QString Helper::verticalBrushIcon = QString(":/Resources/icons/vertical.png");
QString Helper::verticalBrush = QString("Vertical");
Qt::BrushStyle Helper::verticalBrushStyle = Qt::VerPattern;
QString Helper::crossBrushIcon = QString(":/Resources/icons/cross.png");
QString Helper::crossBrush = QString("Cross");
Qt::BrushStyle Helper::crossBrushStyle = Qt::CrossPattern;
QString Helper::forwardBrushIcon = QString(":/Resources/icons/forward.png");
QString Helper::forwardBrush = QString("Forward");
Qt::BrushStyle Helper::forwardBrushStyle = Qt::CrossPattern;
QString Helper::backwardBrushIcon = QString(":/Resources/icons/backward.png");
QString Helper::backwardBrush = QString("Backward");
Qt::BrushStyle Helper::backwardBrushStyle = Qt::CrossPattern;
QString Helper::crossDiagBrushIcon = QString(":/Resources/icons/crossdiag.png");
QString Helper::crossDiagBrush = QString("CrossDiag");
Qt::BrushStyle Helper::crossDiagBrushStyle = Qt::DiagCrossPattern;
QString Helper::horizontalCylinderBrushIcon = QString(":/Resources/icons/horizontalcylinder.png");
QString Helper::horizontalCylinderBrush = QString("HorizontalCylinder");
Qt::BrushStyle Helper::horizontalCylinderBrushStyle = Qt::LinearGradientPattern;
QString Helper::verticalCylinderBrushIcon = QString(":/Resources/icons/verticalcylinder.png");
QString Helper::verticalCylinderBrush = QString("VertitalCylinder");
Qt::BrushStyle Helper::verticalCylinderBrushStyle = Qt::Dense1Pattern;
QString Helper::sphereBrushIcon = QString(":/Resources/icons/sphere.png");
QString Helper::sphereBrush = QString("Sphere");
Qt::BrushStyle Helper::sphereBrushStyle = Qt::RadialGradientPattern;

QString Helper::ModelicaSimulationMethods = "DASSL,DASSL2,Euler,Runge-Kutta";
QString Helper::ModelicaSimulationOutputFormats = "mat,plt,csv,empty";
Expand All @@ -95,7 +142,7 @@ QString GUIMessages::getMessage(int type)
case SAME_COMPONENT_NAME:
return "A Component with the same name already exists. Please choose another Name.";
case SAME_PORT_CONNECT:
return "You can not connect a port to itself.";
return "You cannot connect a port to itself.";
case NO_OPEN_MODEL:
return "There is no open Model to simulate.";
case NO_SIMULATION_STARTTIME:
Expand Down Expand Up @@ -129,7 +176,7 @@ QString GUIMessages::getMessage(int type)
case ONLY_MODEL_ALLOWED:
return "This item is not a model.";
case UNABLE_TO_LOAD_FILE:
return "Error has occurred while loading the file%1. Unable to load the file.";
return "Error has occurred while loading the file '%1'. Unable to load the file.";
case UNABLE_TO_LOAD_MODEL:
return "Error has occurred while loading the model : \n%1.";
case DELETE_AND_LOAD:
Expand All @@ -155,11 +202,15 @@ QString GUIMessages::getMessage(int type)
case CLOSE_INTERACTIVE_SIMULATION_TAB:
return "Are you sure you want to close '%1' interactive simulation?";
case INFO_CLOSE_INTERACTIVE_SIMULATION_TAB:
return "You can not recover this window once its closed.";
return "You cannot recover this window once its closed.";
case INTERACTIVE_SIMULATION_RUNNIG:
return "You already have one interactive simulation running. Only one interactive simulaiton session is allowed at a time. \n\n Please shutdown the interactive simulation or close the interactive simulation tab before launching the new one.";
case SELECT_VARIABLE_FOR_OMI:
return "Please select a variable to plot before starting.";
case DIAGRAM_VIEW_DROP_MSG:
return "You cannot insert %1, it is a %2. Only model, class, connector, record or block are allowed on diagram layer.";
case ICON_VIEW_DROP_MSG:
return "You cannot insert %1, it is a %2. Only connector is allowed on the icon layer.";
default:
return "";
}
Expand Down
51 changes: 50 additions & 1 deletion OMEdit/OMEditGUI/Helper.h
Expand Up @@ -87,6 +87,53 @@ class Helper
static QString omi_stop_button_tooltip;
static QString omi_shutdown_button_tooltip;
static QString omi_showlog_button_tooltip;
// pen styles with icons
static QString solidPenIcon;
static QString solidPen;
static Qt::PenStyle solidPenStyle;
static QString dashPenIcon;
static QString dashPen;
static Qt::PenStyle dashPenStyle;
static QString dotPenIcon;
static QString dotPen;
static Qt::PenStyle dotPenStyle;
static QString dashDotPenIcon;
static QString dashDotPen;
static Qt::PenStyle dashDotPenStyle;
static QString dashDotDotPenIcon;
static QString dashDotDotPen;
static Qt::PenStyle dashDotDotPenStyle;
// brush styles with icons
static QString solidBrushIcon;
static QString solidBrush;
static Qt::BrushStyle solidBrushStyle;
static QString horizontalBrushIcon;
static QString horizontalBrush;
static Qt::BrushStyle horizontalBrushStyle;
static QString verticalBrushIcon;
static QString verticalBrush;
static Qt::BrushStyle verticalBrushStyle;
static QString crossBrushIcon;
static QString crossBrush;
static Qt::BrushStyle crossBrushStyle;
static QString forwardBrushIcon;
static QString forwardBrush;
static Qt::BrushStyle forwardBrushStyle;
static QString backwardBrushIcon;
static QString backwardBrush;
static Qt::BrushStyle backwardBrushStyle;
static QString crossDiagBrushIcon;
static QString crossDiagBrush;
static Qt::BrushStyle crossDiagBrushStyle;
static QString horizontalCylinderBrushIcon;
static QString horizontalCylinderBrush;
static Qt::BrushStyle horizontalCylinderBrushStyle;
static QString verticalCylinderBrushIcon;
static QString verticalCylinderBrush;
static Qt::BrushStyle verticalCylinderBrushStyle;
static QString sphereBrushIcon;
static QString sphereBrush;
static Qt::BrushStyle sphereBrushStyle;
};

class GUIMessages
Expand Down Expand Up @@ -127,7 +174,9 @@ class GUIMessages
CLOSE_INTERACTIVE_SIMULATION_TAB,
INFO_CLOSE_INTERACTIVE_SIMULATION_TAB,
INTERACTIVE_SIMULATION_RUNNIG,
SELECT_VARIABLE_FOR_OMI
SELECT_VARIABLE_FOR_OMI,
DIAGRAM_VIEW_DROP_MSG,
ICON_VIEW_DROP_MSG
};

static QString getMessage(int type);
Expand Down
10 changes: 4 additions & 6 deletions OMEdit/OMEditGUI/InteractiveSimulationTabWidget.cpp
Expand Up @@ -538,8 +538,6 @@ InteractiveSimulationTab::InteractiveSimulationTab(QString filePath, Interactive
// create the plot window
mpPlotWindow = new PlotWindow();
mpPlotWindow->setTitle(tr(""));
mpPlotWindow->getPlot()->setAutoReplot(true);
mpPlotWindow->getPlot()->update();
// create interactive simulation initialize, start, pause, shut down buttons
mpInitializeButton = new QToolButton;
mpInitializeButton->setText(tr("Initialize"));
Expand Down Expand Up @@ -792,6 +790,7 @@ void InteractiveSimulationTab::initializeInteractivePlotting()
{
pPlotCurve->detach();
mpPlotWindow->getPlot()->removeCurve(pPlotCurve);
mpPlotWindow->getPlot()->replot();
}
}

Expand All @@ -818,12 +817,10 @@ void InteractiveSimulationTab::initializeInteractivePlotting()
if (attachFlag)
{
pPlotCurve = new PlotCurve(mpPlotWindow->getPlot());
QPen pen(QColor::fromHsvF(i/(variablesList.length()+1),1,1));
pen.setWidth(2);
pPlotCurve->setPen(pen);
pPlotCurve->setTitle(variable->text());
pPlotCurve->attach(mpPlotWindow->getPlot());
mpPlotWindow->getPlot()->addPlotCurve(pPlotCurve);
mpPlotWindow->getPlot()->replot();
}
}
}
Expand Down Expand Up @@ -890,7 +887,8 @@ void InteractiveSimulationTab::recievedResult(QString message)
double element = variable.mid(variable.lastIndexOf("=") + 1, (variable.length() - 1)).trimmed().toDouble();
pPlotCurve->addXAxisValue(time);
pPlotCurve->addYAxisValue(element);
pPlotCurve->setData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(), pPlotCurve->dataSize());
pPlotCurve->setRawData(pPlotCurve->getXAxisVector(), pPlotCurve->getYAxisVector(), pPlotCurve->getSize());
mpPlotWindow->getPlot()->replot();
count++;
}
}
Expand Down
3 changes: 2 additions & 1 deletion OMEdit/OMEditGUI/LibraryWidget.cpp
Expand Up @@ -766,9 +766,10 @@ void LibraryTree::treeItemPressed(QTreeWidgetItem *item)
// if (mpParentLibraryWidget->mpParentMainWindow->mpOMCProxy->isWhat(StringHandler::PACKAGE, item->toolTip(0)))
// return;

LibraryTreeNode *node = dynamic_cast<LibraryTreeNode*>(item);
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << item->toolTip(0);
dataStream << node->mName << node->mNameStructure << node->mType;

QMimeData *mimeData = new QMimeData;
mimeData->setData("image/modelica-component", itemData);
Expand Down

0 comments on commit d05837c

Please sign in to comment.