Skip to content

Commit

Permalink
- some more updates
Browse files Browse the repository at this point in the history
- fixed zooming and sizing issue of plotting.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8570 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 10, 2011
1 parent 03ab28b commit ee8a9fb
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 40 deletions.
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/Makefile.Debug
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: OMEdit
# Generated by qmake (2.01a) (Qt 4.7.0) on: on 6. apr 19:28:14 2011
# Generated by qmake (2.01a) (Qt 4.7.0) on: fr 8. apr 17:12:07 2011
# Project: OMEditGUI.pro
# Template: app
#############################################################################
Expand Down Expand Up @@ -192,7 +192,7 @@ debug/rc_omedit_res.o: rc_omedit.rc
windres -i rc_omedit.rc -o debug\rc_omedit_res.o --include-dir=. $(DEFINES)

qmake: FORCE
@$(QMAKE) -spec ..\..\..\..\Qt\2010.05\qt\mkspecs\win32-g++ CONFIG+=release -o Makefile.Debug OMEditGUI.pro
@$(QMAKE) -spec ..\..\..\..\Qt\2010.05\qt\mkspecs\win32-g++ -o Makefile.Debug OMEditGUI.pro

dist:
$(ZIP) OMEdit.zip $(SOURCES) $(DIST) OMEditGUI.pro ..\..\..\..\Qt\2010.05\qt\mkspecs\qconfig.pri ..\..\..\..\Qt\2010.05\qt\mkspecs\modules\qt_webkit_version.pri ..\..\..\..\Qt\2010.05\qt\mkspecs\features\qt_functions.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\qt_config.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\exclusive_builds.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\default_pre.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\default_pre.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\debug.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\debug_and_release.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\default_post.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\default_post.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\build_pass.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\warn_off.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\rtti.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\exceptions.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\stl.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\shared.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\qt.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\thread.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\moc.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\windows.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\resources.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\uic.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\yacc.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\lex.prf c:\Qt\2010.05\qt\lib\qtmaind.prl HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/Makefile.Release
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: OMEdit
# Generated by qmake (2.01a) (Qt 4.7.0) on: on 6. apr 19:28:14 2011
# Generated by qmake (2.01a) (Qt 4.7.0) on: fr 8. apr 17:12:07 2011
# Project: OMEditGUI.pro
# Template: app
#############################################################################
Expand Down Expand Up @@ -192,7 +192,7 @@ release/rc_omedit_res.o: rc_omedit.rc
windres -i rc_omedit.rc -o release\rc_omedit_res.o --include-dir=. $(DEFINES)

qmake: FORCE
@$(QMAKE) -spec ..\..\..\..\Qt\2010.05\qt\mkspecs\win32-g++ CONFIG+=release -o Makefile.Release OMEditGUI.pro
@$(QMAKE) -spec ..\..\..\..\Qt\2010.05\qt\mkspecs\win32-g++ -o Makefile.Release OMEditGUI.pro

dist:
$(ZIP) OMEdit.zip $(SOURCES) $(DIST) OMEditGUI.pro ..\..\..\..\Qt\2010.05\qt\mkspecs\qconfig.pri ..\..\..\..\Qt\2010.05\qt\mkspecs\modules\qt_webkit_version.pri ..\..\..\..\Qt\2010.05\qt\mkspecs\features\qt_functions.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\qt_config.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\exclusive_builds.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\default_pre.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\default_pre.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\release.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\debug_and_release.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\default_post.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\default_post.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\build_pass.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\warn_off.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\rtti.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\exceptions.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\stl.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\shared.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\qt.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\thread.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\moc.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\win32\windows.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\resources.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\uic.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\yacc.prf ..\..\..\..\Qt\2010.05\qt\mkspecs\features\lex.prf c:\Qt\2010.05\qt\lib\qtmain.prl HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/ModelWidget.cpp
Expand Up @@ -267,7 +267,6 @@ CheckModelWidget::CheckModelWidget(QString name, QString nameStructure, MainWind
setLayout(mainLayout);
}


FlatModelWidget::FlatModelWidget(QString name, QString nameStructure, MainWindow *pParent)
: QDialog(pParent, Qt::WindowTitleHint), mName(name), mNameStructure(nameStructure)
{
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/ModelWidget.h
Expand Up @@ -98,7 +98,6 @@ class CheckModelWidget : public QDialog
QPushButton *mpOkButton;
};


class FlatModelWidget : public QDialog
{
Q_OBJECT
Expand Down
7 changes: 1 addition & 6 deletions OMEdit/OMEditGUI/OMCProxy.cpp
Expand Up @@ -1194,12 +1194,7 @@ QList<QString> OMCProxy::readSimulationResultVars(QString fileName)
{
sendCommand("readSimulationResultVars(\"" + fileName + "\")");

QList<QString> variablesList;
QStringList list = StringHandler::removeFirstLastCurlBrackets(getResult()).split(",", QString::SkipEmptyParts);
foreach (QString str, list)
{
variablesList.append(StringHandler::removeFirstLastQuotes(str));
}
QList<QString> variablesList = StringHandler::getSimulationResultVars(getResult());
qSort(variablesList.begin(), variablesList.end());
return variablesList;
}
Expand Down
16 changes: 8 additions & 8 deletions OMEdit/OMEditGUI/PlotWidget.cpp
Expand Up @@ -245,8 +245,8 @@ void PlotWidget::plotVariables(QTreeWidgetItem *item, int column)
pPlotWindow->openFile(QString(Helper::tmpPath).append("/").append(parentItem->text(0)));
pPlotWindow->setVariablesList(QStringList(item->toolTip(column).remove(0, (parentItem->text(column).length()+1))));
pPlotWindow->plot();
pPlotWindow->getPlot()->replot();
pPlotWindow->getPlot()->updateGeometry();
pPlotWindow->fitInView();
pPlotWindow->getPlot()->updateLayout();
pPlotWindow->getPlot()->getPlotZoomer()->setZoomBase(false);
}
// if user unchecks the variable then remove it from the plot
Expand All @@ -260,8 +260,8 @@ void PlotWidget::plotVariables(QTreeWidgetItem *item, int column)
{
pPlotWindow->getPlot()->removeCurve(pPlotCurve);
pPlotCurve->detach();
pPlotWindow->getPlot()->replot();
pPlotWindow->getPlot()->updateGeometry();
pPlotWindow->fitInView();
pPlotWindow->getPlot()->updateLayout();
pPlotWindow->getPlot()->getPlotZoomer()->setZoomBase(false);
break;
}
Expand Down Expand Up @@ -293,8 +293,8 @@ void PlotWidget::plotVariables(QTreeWidgetItem *item, int column)
pPlotWindow->setXLabel(tr(""));
pPlotWindow->setYLabel(tr(""));
}
pPlotWindow->getPlot()->replot();
pPlotWindow->getPlot()->updateGeometry();
pPlotWindow->fitInView();
pPlotWindow->getPlot()->updateLayout();
pPlotWindow->getPlot()->getPlotZoomer()->setZoomBase(false);
}
else
Expand Down Expand Up @@ -341,8 +341,8 @@ void PlotWidget::plotVariables(QTreeWidgetItem *item, int column)
mpPlotVariablesTree->blockSignals(false);
pPlotWindow->getPlot()->removeCurve(pPlotCurve);
pPlotCurve->detach();
pPlotWindow->getPlot()->replot();
pPlotWindow->getPlot()->updateGeometry();
pPlotWindow->fitInView();
pPlotWindow->getPlot()->updateLayout();
pPlotWindow->getPlot()->getPlotZoomer()->setZoomBase(false);
break;
}
Expand Down
25 changes: 23 additions & 2 deletions OMEdit/OMEditGUI/PlotWindowContainer.cpp
Expand Up @@ -48,7 +48,6 @@ PlotWindowContainer::PlotWindowContainer(MainWindow *pParent)
setViewMode(QMdiArea::TabbedView);
// dont show this widget at startup
setVisible(false);
addPlotWindow();
}

MainWindow* PlotWindowContainer::getMainWindow()
Expand Down Expand Up @@ -80,6 +79,26 @@ PlotWindow* PlotWindowContainer::getCurrentWindow()
return qobject_cast<PlotWindow*>(subWindowList(QMdiArea::ActivationHistoryOrder).last()->widget());
}

bool PlotWindowContainer::eventFilter(QObject *pObject, QEvent *event)
{
PlotWindow *pPlotWindow = qobject_cast<PlotWindow*>(pObject);
if (!pPlotWindow)
return false;

if (event->type() == QEvent::Paint)
{
QPainter painter (pPlotWindow);
painter.setPen(Qt::gray);
QRect rectangle = pPlotWindow->rect();
rectangle.setWidth(pPlotWindow->rect().width() - 1);
rectangle.setHeight(pPlotWindow->rect().height() - 2);
painter.drawRect(rectangle);
return true;
}

return false;
}

PlotWindow* PlotWindowContainer::addPlotWindow()
{
try
Expand All @@ -88,6 +107,7 @@ PlotWindow* PlotWindowContainer::addPlotWindow()
pPlotWindow->setPlotType(PlotWindow::PLOT);
pPlotWindow->setWindowTitle(getUniqueName(tr("Plot : ")));
pPlotWindow->setTitle(tr(""));
pPlotWindow->installEventFilter(this);
QMdiSubWindow *pSubWindow = addSubWindow(pPlotWindow);
pSubWindow->setWindowIcon(QIcon(":/Resources/icons/plotwindow.png"));
setActiveSubWindow(pSubWindow);
Expand All @@ -111,6 +131,7 @@ PlotWindow* PlotWindowContainer::addPlotParametricWindow()
pPlotWindow->setPlotType(PlotWindow::PLOTPARAMETRIC);
pPlotWindow->setWindowTitle(getUniqueName(tr("Plot Parametric : ")));
pPlotWindow->setTitle(tr(""));
pPlotWindow->installEventFilter(this);
QMdiSubWindow *pSubWindow = addSubWindow(pPlotWindow);
pSubWindow->setWindowIcon(QIcon(":/Resources/icons/plotparametricwindow.png"));
setActiveSubWindow(pSubWindow);
Expand All @@ -137,7 +158,7 @@ void PlotWindowContainer::updatePlotWindows(QTreeWidgetItem *item)
{
pPlotWindow->getPlot()->removeCurve(pPlotCurve);
pPlotCurve->detach();
pPlotWindow->getPlot()->replot();
pPlotWindow->fitInView();
pPlotWindow->getPlot()->updateGeometry();
}
}
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/PlotWindowContainer.h
Expand Up @@ -48,6 +48,7 @@ class PlotWindowContainer : public QMdiArea
MainWindow* getMainWindow();
QString getUniqueName(QString name = QString("Plot"), int number = 1);
OMPlot::PlotWindow* getCurrentWindow();
bool eventFilter(QObject *pObject, QEvent *event);
private:
MainWindow *mpParentMainWindow;
public slots:
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Resources/css/stylesheet.qss
Expand Up @@ -23,7 +23,7 @@ QTreeWidget::item {
}
/* End of Library Widget Styles */

QTextEdit, QLineEdit, QMdiArea {
QTextEdit, QLineEdit {
border: 1px solid gray;
}
QTextEdit#ModelicaEditor {
Expand Down
30 changes: 15 additions & 15 deletions OMEdit/OMEditGUI/ShapeAnnotation.cpp
Expand Up @@ -374,21 +374,21 @@ QVariant ShapeAnnotation::itemChange(GraphicsItemChange change, const QVariant &

void ShapeAnnotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
if (!mpGraphicsView)
{
QGraphicsItem::contextMenuEvent(event);
return;
}

setSelected(true);
QMenu menu(mpGraphicsView->mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow);
menu.addAction(mpGraphicsView->mpRotateIconAction);
menu.addAction(mpGraphicsView->mpRotateAntiIconAction);
menu.addAction(mpGraphicsView->mpResetRotation);
menu.addSeparator();
menu.addAction(mpGraphicsView->mpDeleteIconAction);
menu.addAction(mpShapePropertiesAction);
menu.exec(event->screenPos());
// if (!mpGraphicsView)
// {
// QGraphicsItem::contextMenuEvent(event);
// return;
// }

// setSelected(true);
// QMenu menu(mpGraphicsView->mpParentProjectTab->mpParentProjectTabWidget->mpParentMainWindow);
// menu.addAction(mpGraphicsView->mpRotateIconAction);
// menu.addAction(mpGraphicsView->mpRotateAntiIconAction);
// menu.addAction(mpGraphicsView->mpResetRotation);
// menu.addSeparator();
// menu.addAction(mpGraphicsView->mpDeleteIconAction);
// menu.addAction(mpShapePropertiesAction);
// menu.exec(event->screenPos());
}

ShapeProperties::ShapeProperties(ShapeAnnotation *pShape, MainWindow *pParent)
Expand Down
26 changes: 26 additions & 0 deletions OMEdit/OMEditGUI/StringHandler.cpp
Expand Up @@ -300,6 +300,32 @@ QString StringHandler::removeComment(QString value)
return value.remove(startPos, (endPos - startPos) + 2);
}

QList<QString> StringHandler::getSimulationResultVars(QString value)
{
QList<QString> list;
QString str;
bool startReading = false;

foreach (QChar ch, value)
{
if(startReading)
str.append(ch);

if (ch == '"')
{
if (startReading)
{
startReading = false;
list.append(str.remove((str.length() - 1), 1));
str.clear();
}
else
startReading = true;
}
}
return list;
}

QString StringHandler::getModifierValue(QString value)
{
int element = 0;
Expand Down
5 changes: 3 additions & 2 deletions OMEdit/OMEditGUI/StringHandler.h
Expand Up @@ -46,8 +46,6 @@ class StringHandler
enum ModelicaClasses {MODEL, CLASS, CONNECTOR, RECORD, BLOCK, FUNCTION, PACKAGE, PRIMITIVE, TYPE, PARAMETER,
CONSTANT, PROTECTED};
static QString getModelicaClassType(int type);
// Returns "" if the string is not a standard Modelica string. Else it unparses it into normal form.
static QString unparse(QString value);
static QString getViewType(int type);
static QString removeFirstLastCurlBrackets(QString value);
static QString removeFirstLastBrackets(QString value);
Expand All @@ -62,6 +60,9 @@ class StringHandler
static QString removeLastWordAfterDot(QString value);
static QString removeComment(QString value);
static QString getModifierValue(QString value);
static QList<QString> getSimulationResultVars(QString value);
// Returns "" if the string is not a standard Modelica string. Else it unparses it into normal form.
static QString unparse(QString value);
};

#endif // STRINGHANDLER_H
4 changes: 4 additions & 0 deletions OMEdit/OMEditGUI/mainwindow.cpp
Expand Up @@ -1029,6 +1029,10 @@ void MainWindow::switchToModelingView()

void MainWindow::switchToPlottingView()
{
// if not plotwindow is opened then open one for user
if (mpPlotWindowContainer->subWindowList().size() == 0)
mpPlotWindowContainer->addPlotWindow();

plottingViewAction->setChecked(true);
mpProjectTabs->setVisible(false);
mpInteractiveSimualtionTabWidget->setVisible(false);
Expand Down

0 comments on commit ee8a9fb

Please sign in to comment.