Skip to content

Commit

Permalink
- Updated the OMPlot tool.
Browse files Browse the repository at this point in the history
- Now supports interactive simulation as well.
- Added a namespace OMPlot, so that if one is using a lib the classes don't conflict.
- Created classes for each Plot feature.
- More work on the structure of the code is required.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8208 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Mar 14, 2011
1 parent 38c1da9 commit ac2d895
Show file tree
Hide file tree
Showing 20 changed files with 1,163 additions and 217 deletions.
47 changes: 47 additions & 0 deletions OMPlot/OMPlotGUI/Legend.cpp
@@ -0,0 +1,47 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linkoping University,
* Department of Computer and Information Science,
* SE-58183 Linkoping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linkoping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
* Main Author 2011: Adeel Asghar
*
*/

#include "Legend.h"

using namespace OMPlot;

Legend::Legend(Plot *pParent)
{

}

Legend::~Legend()
{

}

51 changes: 51 additions & 0 deletions OMPlot/OMPlotGUI/Legend.h
@@ -0,0 +1,51 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linkoping University,
* Department of Computer and Information Science,
* SE-58183 Linkoping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linkoping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
* Main Author 2011: Adeel Asghar
*
*/

#ifndef LEGEND_H
#define LEGEND_H

#include "Plot.h"

namespace OMPlot
{
class Plot;

class Legend : public QwtLegend
{
public:
Legend(Plot *pParent);
~Legend();
};
}

#endif // LEGEND_H
34 changes: 25 additions & 9 deletions OMPlot/OMPlotGUI/OMPlotGUI.pro
Expand Up @@ -4,27 +4,43 @@
#
#-------------------------------------------------

QT += core gui
QT += core gui

TARGET = OMPlot
TEMPLATE = app

CONFIG += release

SOURCES += main.cpp \
plotwindow.cpp \
../../c_runtime/read_matlab4.c

HEADERS += plotwindow.h \
../../c_runtime/read_matlab4.h
../../c_runtime/read_matlab4.c \
Plot.cpp \
PlotCanvas.cpp \
PlotZoomer.cpp \
Legend.cpp \
PlotPanner.cpp \
PlotGrid.cpp \
PlotCurve.cpp \
PlotPicker.cpp \
PlotWindow.cpp

HEADERS += ../../c_runtime/read_matlab4.h \
Plot.h \
PlotCanvas.h \
PlotZoomer.h \
Legend.h \
PlotPanner.h \
PlotGrid.h \
PlotCurve.h \
PlotPicker.h \
PlotWindow.h

win32 {
LIBS += -L$$(OMDEV)/lib/qwt-5.2.1-mingw/lib -lqwt5
LIBS += -L$$(OMDEV)/lib/qwt-5.2.1-mingw/lib -lqwtd5
INCLUDEPATH += $$(OMDEV)/lib/qwt-5.2.1-mingw/include
} else {
include(OMPlotGUI.config)
}

INCLUDEPATH += .

CONFIG += warn_off

DESTDIR = ../bin
Expand Down
114 changes: 114 additions & 0 deletions OMPlot/OMPlotGUI/Plot.cpp
@@ -0,0 +1,114 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linkoping University,
* Department of Computer and Information Science,
* SE-58183 Linkoping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linkoping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
* Main Author 2011: Adeel Asghar
*
*/

#include "PlotWindow.h"

using namespace OMPlot;

Plot::Plot(PlotWindow *pParent)
: QwtPlot(pParent)
{
mpParentPlotWindow = pParent;

setTitle(tr("Plot by OpenModelica"));
setCanvasBackground(Qt::white);
// create an instance of legend
mpLegend = new Legend(this);
insertLegend(mpLegend, QwtPlot::RightLegend);
// create an instance of picker
mpPlotPicker = new PlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, canvas());
// create an instance of grid
mpPlotGrid = new PlotGrid(this);
// create an instance of zoomer
mpPlotZoomer = new PlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, canvas());
// create an instance of panner
mpPlotPanner = new PlotPanner(canvas());
// create an instance of canvas we use it to capture events of canvas()
mpPlotCanvas = new PlotCanvas(this);
canvas()->installEventFilter(mpPlotCanvas);
}

Plot::~Plot()
{

}

PlotWindow* Plot::getParentPlotWindow()
{
return mpParentPlotWindow;
}

Legend* Plot::getLegend()
{
return mpLegend;
}

PlotPicker* Plot::getPlotPicker()
{
return mpPlotPicker;
}

PlotGrid* Plot::getPlotGrid()
{
return mpPlotGrid;
}

PlotZoomer* Plot::getPlotZoomer()
{
return mpPlotZoomer;
}

PlotPanner* Plot::getPlotPanner()
{
return mpPlotPanner;
}

QList<PlotCurve*> Plot::getPlotCurvesList()
{
return mPlotCurvesList;
}

PlotCanvas* Plot::getPlotCanvas()
{
return mpPlotCanvas;
}

void Plot::addPlotCurve(PlotCurve *pCurve)
{
mPlotCurvesList.append(pCurve);
}

void Plot::removeCurve(PlotCurve *pCurve)
{
mPlotCurvesList.removeOne(pCurve);
}
86 changes: 86 additions & 0 deletions OMPlot/OMPlotGUI/Plot.h
@@ -0,0 +1,86 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linkoping University,
* Department of Computer and Information Science,
* SE-58183 Linkoping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linkoping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
* Main Author 2011: Adeel Asghar
*
*/

#ifndef PLOT_H
#define PLOT_H

#include "PlotWindow.h"
#include "Legend.h"
#include "PlotPicker.h"
#include "PlotGrid.h"
#include "PlotZoomer.h"
#include "PlotPanner.h"
#include "PlotCurve.h"
#include "PlotCanvas.h"

namespace OMPlot
{
class PlotWindow;
class Legend;
class PlotPicker;
class PlotGrid;
class PlotZoomer;
class PlotPanner;
class PlotCurve;
class PlotCanvas;

class Plot : public QwtPlot
{
Q_OBJECT
private:
PlotWindow *mpParentPlotWindow;
Legend *mpLegend;
PlotPicker *mpPlotPicker;
PlotGrid *mpPlotGrid;
PlotZoomer *mpPlotZoomer;
PlotPanner *mpPlotPanner;
QList<PlotCurve*> mPlotCurvesList;
PlotCanvas *mpPlotCanvas;
public:
Plot(PlotWindow *pParent);
~Plot();

PlotWindow* getParentPlotWindow();
Legend* getLegend();
PlotPicker* getPlotPicker();
PlotGrid* getPlotGrid();
PlotZoomer* getPlotZoomer();
PlotPanner* getPlotPanner();
QList<PlotCurve*> getPlotCurvesList();
PlotCanvas* getPlotCanvas();
void addPlotCurve(PlotCurve *pCurve);
void removeCurve(PlotCurve *pCurve);
};
}

#endif // PLOT_H

0 comments on commit ac2d895

Please sign in to comment.