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 f3d37bc commit e44a358
Show file tree
Hide file tree
Showing 11 changed files with 477 additions and 420 deletions.
42 changes: 39 additions & 3 deletions OMPlot/OMPlotGUI/Plot.cpp
Expand Up @@ -41,12 +41,9 @@ Plot::Plot(PlotWindow *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 QwtPlotPicker(canvas());
mpPlotPicker->setTrackerPen(QPen(Qt::black));
Expand All @@ -60,13 +57,33 @@ Plot::Plot(PlotWindow *pParent)
mpPlotPanner = new PlotPanner(canvas(), this);
// set canvas arrow
canvas()->setCursor(Qt::ArrowCursor);
setCanvasBackground(Qt::white);
setContentsMargins(10, 10, 10, 10);
// fill colors list
fillColorsList();
}

Plot::~Plot()
{

}

void Plot::fillColorsList()
{
mColorsList.append(QColor(Qt::red));
mColorsList.append(QColor(Qt::blue));
mColorsList.append(QColor(Qt::green));
mColorsList.append(QColor(Qt::cyan));
mColorsList.append(QColor(Qt::magenta));
mColorsList.append(QColor(Qt::yellow));
mColorsList.append(QColor(Qt::darkRed));
mColorsList.append(QColor(Qt::darkBlue));
mColorsList.append(QColor(Qt::darkGreen));
mColorsList.append(QColor(Qt::darkCyan));
mColorsList.append(QColor(Qt::darkMagenta));
mColorsList.append(QColor(Qt::darkYellow));
}

PlotWindow* Plot::getParentPlotWindow()
{
return mpParentPlotWindow;
Expand Down Expand Up @@ -111,3 +128,22 @@ void Plot::removeCurve(PlotCurve *pCurve)
{
mPlotCurvesList.removeOne(pCurve);
}

QColor Plot::getUniqueColor(int index, int total)
{
if (mColorsList.size() < total)
return QColor::fromHsvF(index/(total + 1.0), 1, 1);
else
return mColorsList.at(index);
}

void Plot::replot()
{
// just overloaded this function to get colors for curves.
for (int i = 0 ; i < mPlotCurvesList.length() ; i++)
{
mPlotCurvesList[i]->setPen(getUniqueColor(i, mPlotCurvesList.length()));
}

QwtPlot::replot();
}
5 changes: 5 additions & 0 deletions OMPlot/OMPlotGUI/Plot.h
Expand Up @@ -61,10 +61,12 @@ class Plot : public QwtPlot
PlotZoomer *mpPlotZoomer;
PlotPanner *mpPlotPanner;
QList<PlotCurve*> mPlotCurvesList;
QList<QColor> mColorsList;
public:
Plot(PlotWindow *pParent);
~Plot();

void fillColorsList();
PlotWindow* getParentPlotWindow();
Legend* getLegend();
QwtPlotPicker* getPlotPicker();
Expand All @@ -74,6 +76,9 @@ class Plot : public QwtPlot
QList<PlotCurve*> getPlotCurvesList();
void addPlotCurve(PlotCurve *pCurve);
void removeCurve(PlotCurve *pCurve);
QColor getUniqueColor(int index, int total);
public slots:
virtual void replot();
};
}

Expand Down
30 changes: 30 additions & 0 deletions OMPlot/OMPlotGUI/PlotCurve.cpp
Expand Up @@ -82,6 +82,36 @@ int PlotCurve::getSize()
return mXAxisVector.size();
}

void PlotCurve::setFileName(QString fileName)
{
mFileName = fileName;
}

QString PlotCurve::getFileName()
{
return mFileName;
}

void PlotCurve::setXVariable(QString xVariable)
{
mXVariable = xVariable;
}

QString PlotCurve::getXVariable()
{
return mXVariable;
}

void PlotCurve::setYVariable(QString yVariable)
{
mYVariable = yVariable;
}

QString PlotCurve::getYVariable()
{
return mYVariable;
}

void PlotCurve::updateLegend(QwtLegend *legend) const
{
QwtPlotCurve::updateLegend(legend);
Expand Down
9 changes: 9 additions & 0 deletions OMPlot/OMPlotGUI/PlotCurve.h
Expand Up @@ -43,6 +43,9 @@ class PlotCurve : public QwtPlotCurve
private:
QwtArray<double> mXAxisVector;
QwtArray<double> mYAxisVector;
QString mFileName;
QString mXVariable;
QString mYVariable;

Plot *mpParentPlot;
public:
Expand All @@ -56,6 +59,12 @@ class PlotCurve : public QwtPlotCurve
void addYAxisValue(double value);
const double* getYAxisVector() const;
int getSize();
void setFileName(QString fileName);
QString getFileName();
void setXVariable(QString xVariable);
QString getXVariable();
void setYVariable(QString yVariable);
QString getYVariable();
virtual void updateLegend(QwtLegend *legend) const;
};
}
Expand Down
1 change: 1 addition & 0 deletions OMPlot/OMPlotGUI/PlotGrid.cpp
Expand Up @@ -38,6 +38,7 @@ using namespace OMPlot;
PlotGrid::PlotGrid(Plot *pParent)
{
attach(pParent);
setPen(QPen(Qt::lightGray));
}

PlotGrid::~PlotGrid()
Expand Down
1 change: 0 additions & 1 deletion OMPlot/OMPlotGUI/PlotMainWindow.cpp
Expand Up @@ -72,7 +72,6 @@ void PlotMainWindow::createActions()

mpTabViewAction = new QAction(tr("Tab View"), this);
mpTabViewAction->setCheckable(true);
mpTabViewAction->setChecked(true);
connect(mpTabViewAction, SIGNAL(triggered(bool)), SLOT(switchWindowsView(bool)));
}

Expand Down

0 comments on commit e44a358

Please sign in to comment.