Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2851 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Henrik Eriksson committed Jun 26, 2007
1 parent 78950cf commit 3009848
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 20 deletions.
3 changes: 2 additions & 1 deletion OMNotebook/Pltpkg2/LegendLabel.h
Expand Up @@ -68,7 +68,7 @@ class LegendLabel: public QLabel
Q_OBJECT

public:
LegendLabel(QColor color_, QString& s, QWidget* parent);
LegendLabel(QColor color_, QString& s, QWidget* parent, bool showline, bool showpoints);
~LegendLabel();

void setCurve(Curve* c)
Expand Down Expand Up @@ -103,6 +103,7 @@ public slots:
QMenu *menu;
Curve* curve;
bool state;

};

#endif
19 changes: 11 additions & 8 deletions OMNotebook/Pltpkg2/Pltpkg2.vcproj
Expand Up @@ -166,36 +166,36 @@
</FileConfiguration>
</File>
<File
RelativePath="debug\moc_graphWidget.cpp">
RelativePath="release\moc_graphWidget.cpp">
<FileConfiguration
Name="Release|Win32"
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath="release\moc_graphWidget.cpp">
RelativePath="debug\moc_graphWidget.cpp">
<FileConfiguration
Name="Debug|Win32"
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath="release\moc_graphWindow.cpp">
RelativePath="debug\moc_graphWindow.cpp">
<FileConfiguration
Name="Debug|Win32"
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath="debug\moc_graphWindow.cpp">
RelativePath="release\moc_graphWindow.cpp">
<FileConfiguration
Name="Release|Win32"
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
Expand Down Expand Up @@ -254,6 +254,9 @@
<File
RelativePath="dataSelect.h">
</File>
<File
RelativePath=".\focusRect.h">
</File>
<File
RelativePath=".\graphScene.h">
</File>
Expand Down
51 changes: 51 additions & 0 deletions OMNotebook/Pltpkg2/focusRect.h
@@ -0,0 +1,51 @@
#ifndef FOCUSRECT_H
#define FOCUSRECT_H

#include <QGraphicsRectItem>
#include <QBrush>
#include "graphWidget.h"
#include <QMessageBox>

class FocusRect: public QGraphicsRectItem
{

public:
FocusRect(const QRectF& rect, GraphWidget* w): QGraphicsRectItem(rect), widget(w)
{
setAcceptsHoverEvents(true);
setZValue(-2);
}

~FocusRect()
{
}

void hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
{
QColor c(0, 255, 0, 50);
QBrush b(c);
setBrush(b);
}

void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
{
QColor c(255, 0, 0, 50);
QBrush b(c);
setBrush(b);
}

void mousePressEvent ( QGraphicsSceneMouseEvent * event )
{


widget->zoomIn(rect());
widget->updatePointSizes(QRect(-1,0,0,0));
}

GraphWidget* widget;



};

#endif
65 changes: 55 additions & 10 deletions OMNotebook/Pltpkg2/graphWidget.cpp
Expand Up @@ -86,6 +86,7 @@ licence: http://www.trolltech.com/products/qt/licensing.html
#include "point.h"
#include "LegendLabel.h"
#include "curve.h"
#include "focusRect.h"

#include <QtOpengL/QGLWidget>
using namespace std;
Expand Down Expand Up @@ -147,6 +148,8 @@ GraphWidget::GraphWidget(QWidget* parent): QGraphicsView(parent)
QAction* a;
foreach(a, ag->actions())
a->setCheckable(true);

tmp->setChecked(true);

contextMenu->addSeparator();

Expand All @@ -172,20 +175,28 @@ GraphWidget::GraphWidget(QWidget* parent): QGraphicsView(parent)
*/
tmp=contextMenu->addAction("New window");
connect(tmp, SIGNAL(triggered()), this, SLOT(newWindow()));
tmp->setVisible(false);

tmp=contextMenu->addAction("Preferences");
connect(tmp, SIGNAL(triggered()), this, SLOT(showPreferences()));

// connect(this, SIGNAL(scrolled()), this, SLOT(updateGrid()));


tmp = contextMenu->addAction("Antialiasing");
tmp->setCheckable(true);
connect(tmp, SIGNAL(toggled(bool)), this, SLOT(setAntiAliasing(bool)));

contextMenu->addSeparator();

tmp=contextMenu->addAction("Preferences");
connect(tmp, SIGNAL(triggered()), this, SLOT(showPreferences()));


tmp = contextMenu->addAction("oZm");
connect(tmp, SIGNAL(triggered()), this, SLOT(originalZoom()));
tmp->setVisible(false);

tmp = contextMenu->addAction("Add focus box");
connect(tmp, SIGNAL(triggered()), this, SLOT(addFocusBox()));
tmp->setVisible(false);

graphicsItems = new QGraphicsItemGroup;
dataPoints = new QList<Point*>;
Expand All @@ -198,9 +209,11 @@ GraphWidget::GraphWidget(QWidget* parent): QGraphicsView(parent)
doFitInView = false;
hold = false;

#if QT_VERSION >= 0x040300
setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing|QGraphicsView::DontSavePainterState);
#endif
setZoom(true);

//#if QT_VERSION >= 0x040300
// setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing|QGraphicsView::DontSavePainterState);
//#endif
}

void GraphWidget::originalZoom()
Expand All @@ -209,6 +222,15 @@ void GraphWidget::originalZoom()
setArea(originalArea);
updatePointSizes();
}

void GraphWidget::addFocusBox()
{
FocusRect* r = new FocusRect(currentArea(), this);

graphicsScene->addItem(r);
r->show();

}
void GraphWidget::newWindow()
{
GraphWindow* g = new GraphWindow(0);
Expand Down Expand Up @@ -537,7 +559,13 @@ void GraphWidget::mouseReleaseEvent ( QMouseEvent * event )
bottom += mapToScene(0,0,0,this->horizontalScrollBar()->height()).boundingRect().height();
right += mapToScene(0,0,this->verticalScrollBar()->width(), 0).boundingRect().width();

fitInView(QRectF(left, bottom, right-left, top-bottom));
QRectF r(left, bottom, right-left, top-bottom);

if(!r.width() || !r.height())
return;


fitInView(r);

double xScale = matrix().m11()/125;
double yScale = -matrix().m22()/200;
Expand Down Expand Up @@ -1479,10 +1507,23 @@ void GraphWidget::plotPtolemyDataStream()
currentXVar = tmp;
else
{



if(yVars.indexOf(tmp) == -1)
{
int interpolation_;

if(interpolation == QString("constant"))
interpolation_ = INTERPOLATION_CONSTANT;
else if(interpolation == QString("linear"))
interpolation_ = INTERPOLATION_LINEAR;
else
interpolation_ = INTERPOLATION_NONE;


yVars.push_back(tmp);
ll = new LegendLabel(color, tmp,legendFrame);
ll = new LegendLabel(color, tmp,legendFrame, !(interpolation_ == INTERPOLATION_NONE), points);
ll->graphWidget = this;

ll->setMaximumHeight(21);
Expand All @@ -1492,8 +1533,11 @@ void GraphWidget::plotPtolemyDataStream()
temporaryCurves[tmp] = (new Curve(variables[currentXVar], variables[tmp], color, ll));
ll->setCurve(temporaryCurves[tmp]);

}
temporaryCurves[tmp]->drawPoints = points;
temporaryCurves[tmp]->interpolation = interpolation_;

}
/*
if(interpolation == QString("constant"))
temporaryCurves[tmp]->interpolation = INTERPOLATION_CONSTANT;
else if(interpolation == QString("linear"))
Expand All @@ -1502,7 +1546,8 @@ void GraphWidget::plotPtolemyDataStream()
temporaryCurves[tmp]->interpolation = INTERPOLATION_NONE;
temporaryCurves[tmp]->drawPoints = points;
}
*/
}
}

packetSize = 0;
Expand Down
2 changes: 2 additions & 0 deletions OMNotebook/Pltpkg2/graphWidget.h
Expand Up @@ -154,6 +154,7 @@ public slots:
void setHold(QDataStream& ds);

void originalZoom();
void addFocusBox();

signals:
void showPreferences2();
Expand Down Expand Up @@ -241,6 +242,7 @@ public slots:

QRectF currentArea_;



public:
QRectF originalArea;
Expand Down
4 changes: 3 additions & 1 deletion OMNotebook/Pltpkg2/legendLabel.cpp
Expand Up @@ -53,19 +53,21 @@ licence: http://www.trolltech.com/products/qt/licensing.html
#include "LegendLabel.h"
#include "curve.h"

LegendLabel::LegendLabel(QColor color_, QString& s, QWidget* parent): QLabel(s, parent), color(color_)
LegendLabel::LegendLabel(QColor color_, QString& s, QWidget* parent, bool showline, bool showpoints): QLabel(s, parent), color(color_)
{
state = true;
setContextMenuPolicy(Qt::ActionsContextMenu);
QAction* tmp;
tmp = new QAction(QString("Show line"), this);
tmp->setCheckable(true);
tmp->setChecked(showline);
connect(tmp, SIGNAL(toggled(bool)), this, SLOT(setLineVisible(bool)));
connect(this, SIGNAL(showLine(bool)), tmp, SLOT(setChecked(bool)));
addAction(tmp);

tmp = new QAction("Show data points", this);
tmp->setCheckable(true);
tmp->setChecked(showpoints);
connect(tmp, SIGNAL(toggled(bool)), this, SLOT(setPointsVisible(bool)));
connect(this, SIGNAL(showPoints(bool)), tmp, SLOT(setChecked(bool)));
addAction(tmp);
Expand Down

0 comments on commit 3009848

Please sign in to comment.