Skip to content

Commit

Permalink
- All clients runtimes are moved to OMTools/bin
Browse files Browse the repository at this point in the history
- All required qt libs are moved to OMTools/qtdlls
- Some updates in OMPlot and OMEdit
- plotParametric3 and plotAll3 is added.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8524 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Apr 6, 2011
1 parent 67a0281 commit dc73d9c
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 64 deletions.
2 changes: 1 addition & 1 deletion OMPlot/OMPlotGUI/OMPlotGUI.pro
Expand Up @@ -4,7 +4,7 @@
#
#-------------------------------------------------

QT += core gui
QT += core gui svg

TARGET = OMPlot
TEMPLATE = app
Expand Down
14 changes: 8 additions & 6 deletions OMPlot/OMPlotGUI/Plot.cpp
Expand Up @@ -39,28 +39,30 @@ using namespace OMPlot;
Plot::Plot(PlotWindow *pParent)
: QwtPlot(pParent)
{
setAutoReplot(false);
mpParentPlotWindow = pParent;

// 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));
mpPlotPicker->setRubberBandPen(QPen(Qt::black));
mpPlotPicker->setTrackerMode(QwtPicker::AlwaysOn);
// create an instance of grid
mpPlotGrid = new PlotGrid(this);
// create an instance of zoomer
mpPlotZoomer = new PlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, canvas());
mpPlotZoomer = new PlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, canvas());
// create an instance of panner
mpPlotPanner = new PlotPanner(canvas(), this);
// create an instance of picker
mpPlotPicker = new QwtPlotPicker(canvas());
mpPlotPicker->setTrackerPen(QPen(Qt::black));
mpPlotPicker->setRubberBandPen(QPen(Qt::black));
mpPlotPicker->setTrackerMode(QwtPicker::AlwaysOn);
// set canvas arrow
canvas()->setCursor(Qt::ArrowCursor);
setCanvasBackground(Qt::white);
setContentsMargins(10, 10, 10, 10);
// fill colors list
fillColorsList();
setAutoReplot(true);
}

Plot::~Plot()
Expand Down
5 changes: 4 additions & 1 deletion OMPlot/OMPlotGUI/PlotGrid.cpp
Expand Up @@ -38,7 +38,10 @@ using namespace OMPlot;
PlotGrid::PlotGrid(Plot *pParent)
{
attach(pParent);
setPen(QPen(Qt::lightGray));
setMajPen(QPen(Qt::gray));
enableXMin(true);
enableYMin(true);
setMinPen(QPen(Qt::lightGray, 0.0, Qt::DotLine));
}

PlotGrid::~PlotGrid()
Expand Down
1 change: 1 addition & 0 deletions OMPlot/OMPlotGUI/PlotPanner.cpp
Expand Up @@ -42,6 +42,7 @@ PlotPanner::PlotPanner(QwtPlotCanvas *pCanvas, Plot *pParent)
setEnabled(false);
connect(this, SIGNAL(moved(int,int)), SLOT(updateView(int, int)));
mpParentPlot = pParent;

}

PlotPanner::~PlotPanner()
Expand Down
82 changes: 42 additions & 40 deletions OMPlot/OMPlotGUI/PlotWindow.cpp
Expand Up @@ -31,6 +31,7 @@
*
*/

#include <QtSvg/QSvgGenerator>
#include "PlotWindow.h"
#include "iostream"

Expand All @@ -45,6 +46,7 @@ PlotWindow::PlotWindow(QStringList arguments, QWidget *parent)
if (arguments.size() > 1)
initializePlot(arguments);
// set qwtplot the central widget
mpPlot->getPlotZoomer()->setZoomBase(false);
setCentralWidget(getPlot());
}

Expand All @@ -60,7 +62,6 @@ void PlotWindow::setUpWidget()
// set up the toolbar
setupToolbar();
// enable the zoom mode by default
enableZoomMode(true);
mpZoomButton->setChecked(true);
// set the default values
// set the plot title
Expand Down Expand Up @@ -178,10 +179,20 @@ void PlotWindow::setupToolbar()
//ORIGINAL SIZE
QToolButton *originalButton = new QToolButton(toolBar);
originalButton->setText("Original");
//btnExport->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
connect(originalButton, SIGNAL(clicked()), SLOT(setOriginal()));
toolBar->addWidget(originalButton);
toolBar->addSeparator();
//Fit in View
QToolButton *fitInViewButton = new QToolButton(toolBar);
fitInViewButton->setText("Fit in View");
connect(fitInViewButton, SIGNAL(clicked()), SLOT(fitInView()));
toolBar->addWidget(fitInViewButton);
toolBar->addSeparator();
// make the buttons exclusive
QButtonGroup *pViewsButtonGroup = new QButtonGroup;
pViewsButtonGroup->setExclusive(true);
pViewsButtonGroup->addButton(mpZoomButton);
pViewsButtonGroup->addButton(mpPanButton);
//EXPORT
QToolButton *btnExport = new QToolButton(toolBar);
btnExport->setText("Save");
Expand Down Expand Up @@ -406,14 +417,15 @@ void PlotWindow::plot()
void PlotWindow::plotParametric()
{
QString currentLine, xVariable, yVariable;
QVector<int> variableExists(2);
if (mVariablesList.isEmpty())
throw NoVariableException(QString("No variables specified!").toStdString().c_str());
else if (mVariablesList.size() != 2)
throw NoVariableException(QString("Please specify two variables for plotParametric.").toStdString().c_str());

xVariable = mVariablesList.at(0);
yVariable = mVariablesList.at(1);
setXLabel(xVariable);
setYLabel(yVariable);

//PLOT PLT
if (mFile.fileName().endsWith("plt"))
Expand Down Expand Up @@ -647,20 +659,8 @@ void PlotWindow::enableZoomMode(bool on)
{
mpPlot->getPlotZoomer()->setEnabled(on);
if(on)
{
if(mpPlot->getPlotPanner()->isEnabled())
{
mpPlot->getPlotPanner()->setEnabled(false);
mpPanButton->setChecked(false);
}
mpPlot->canvas()->setCursor(Qt::CrossCursor);
}
else
{
if(!mpPlot->getPlotPanner()->isEnabled())
mpPlot->getPlotPicker()->setRubberBand(QwtPlotPicker::CrossRubberBand);

mpPlot->canvas()->setCursor(Qt::ArrowCursor);
mpPlot->canvas()->setCursor(Qt::CrossCursor);
}
}

Expand All @@ -669,36 +669,32 @@ void PlotWindow::enablePanMode(bool on)
mpPlot->getPlotPanner()->setEnabled(on);
if(on)
{
mpPlot->getPlotPicker()->setRubberBand(QwtPlotPicker::NoRubberBand);
if(mpPlot->getPlotZoomer()->isEnabled())
{
mpZoomButton->setChecked(false);
enableZoomMode(false);
}
mpPlot->canvas()->setCursor(Qt::OpenHandCursor);
}
else
{
if(!mpPlot->getPlotZoomer()->isEnabled())
{
mpPlot->getPlotPicker()->setRubberBand(QwtPlotPicker::CrossRubberBand);
mpPlot->canvas()->setCursor(Qt::CrossCursor);
}
mpPlot->canvas()->setCursor(Qt::ArrowCursor);
}
}

void PlotWindow::exportDocument()
{
//Include ps ;;Postscript Documents (*.ps)
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File As"), QDir::currentPath(), tr("Image Files (*.png *.bmp *.jpg)"));
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File As"), QDir::currentPath(), tr("Image Files (*.png *.svg *.bmp *.jpg)"));

if ( !fileName.isEmpty() )
{
QPixmap pixmap(mpPlot->size());
mpPlot->render(&pixmap);
if (!pixmap.save(fileName)) {
QMessageBox::critical(this, "Error", "Failed to save image " + fileName);
{
// export svg
if (fileName.endsWith(".svg"))
{
QSvgGenerator generator;
generator.setFileName(fileName);
generator.setSize(getPlot()->rect().size());
getPlot()->print(generator);
}
// export png, bmp, jpg
else
{
QPixmap pixmap(mpPlot->size());
mpPlot->render(&pixmap);
if (!pixmap.save(fileName)) {
QMessageBox::critical(this, "Error", "Failed to save image " + fileName);
}
}
}
}
Expand Down Expand Up @@ -748,9 +744,15 @@ void PlotWindow::setGrid(bool on)

void PlotWindow::setOriginal()
{
mpPlot->getPlotZoomer()->zoom(0);
mpPlot->replot();
}

void PlotWindow::fitInView()
{
mpPlot->getPlotZoomer()->zoom(0);
mpPlot->setAxisAutoScale(QwtPlot::yLeft);
mpPlot->setAxisAutoScale(QwtPlot::xBottom);
// mpPlot->getPlotZoomer()->zoom(0);
mpPlot->replot();
}

Expand Down
1 change: 1 addition & 0 deletions OMPlot/OMPlotGUI/PlotWindow.h
Expand Up @@ -94,6 +94,7 @@ public slots:
void printPlot();
void setGrid(bool on);
void setOriginal();
void fitInView();
void setLogX(bool on);
void setLogY(bool on);
};
Expand Down
5 changes: 4 additions & 1 deletion OMPlot/OMPlotGUI/PlotWindowContainer.cpp
Expand Up @@ -69,7 +69,10 @@ QString PlotWindowContainer::getUniqueName(QString name, int number)

PlotWindow* PlotWindowContainer::getCurrentWindow()
{
return qobject_cast<PlotWindow*>(currentSubWindow()->widget());
if (subWindowList(QMdiArea::ActivationHistoryOrder).size() == 0)
return 0;
else
return qobject_cast<PlotWindow*>(subWindowList(QMdiArea::ActivationHistoryOrder).last()->widget());
}

void PlotWindowContainer::addPlotWindow(QStringList arguments)
Expand Down
19 changes: 5 additions & 14 deletions OMPlot/OMPlotGUI/PlotZoomer.cpp
Expand Up @@ -35,30 +35,21 @@

using namespace OMPlot;

PlotZoomer::PlotZoomer(int xAxis, int yAxis, QwtPlotCanvas *pParent, bool doReplot)
: QwtPlotZoomer(xAxis, yAxis, pParent, doReplot)
PlotZoomer::PlotZoomer(int xAxis, int yAxis, QwtPlotCanvas *pParent)
: QwtPlotZoomer(xAxis, yAxis, pParent)
{
setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner);
setTrackerMode(QwtPicker::AlwaysOff);
setRubberBand(QwtPicker::RectRubberBand);
setRubberBandPen(QPen(Qt::black));
setRubberBandPen(QPen(Qt::black, 1.0, Qt::DashLine));

// RightButton: zoom out by 1
// Ctrl+RightButton: zoom out to full size

#if QT_VERSION < 0x040000
setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlButton);
#else
setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
#endif
setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
}

PlotZoomer::~PlotZoomer()
{

}

3 changes: 2 additions & 1 deletion OMPlot/OMPlotGUI/PlotZoomer.h
Expand Up @@ -40,8 +40,9 @@ namespace OMPlot
{
class PlotZoomer : public QwtPlotZoomer
{
Q_OBJECT
public:
PlotZoomer(int xAxis, int yAxis, QwtPlotCanvas *pParent, bool doReplot = true);
PlotZoomer(int xAxis, int yAxis, QwtPlotCanvas *pParent);
~PlotZoomer();
};
}
Expand Down

0 comments on commit dc73d9c

Please sign in to comment.