#include "Plot2d_Curve.h"
#include "Plot2d_PlotItems.h"
#include "Plot2d_FitDataDlg.h"
+#ifndef NO_SUIT
#include "Plot2d_ViewWindow.h"
+#endif
#include "Plot2d_SetupViewDlg.h"
+#ifndef NO_ANALYTICAL_CURVES
#include "Plot2d_AnalyticalCurveDlg.h"
#include "Plot2d_AnalyticalCurve.h"
+#endif
#include "Plot2d_ToolTip.h"
+#ifndef NO_SUIT
#include "SUIT_Tools.h"
#include "SUIT_Session.h"
#include "SUIT_MessageBox.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Application.h"
+#else
+#include <QMessageBox>
+#endif
#include <QApplication>
#include <QToolBar>
#define FITALL_EVENT ( QEvent::User + 9999 )
-const char* imageZoomCursor[] = {
+const char* imageZoomCursor[] = {
"32 32 3 1",
". c None",
"a c #000000",
"................................",
"................................"};
-const char* imageCrossCursor[] = {
+const char* imageCrossCursor[] = {
"32 32 3 1",
". c None",
"a c #000000",
#undef min
#endif
#endif
-
+
/*!
Constructor
*/
Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
: QWidget (parent, 0),
- myOperation( NoOpId ),
- myCurveType( 1 ),
+ myOperation( NoOpId ),
+ myCurveType( 1 ),
myShowLegend( true ), myLegendPos( 1 ), myLegendFont("Helvetic",12),
myLegendColor(Qt::black),
myMarkerSize( DEFAULT_MARKER_SIZE ),
myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ),
myTitleEnabled( true ), myXTitleEnabled( true ),
myYTitleEnabled( true ), myY2TitleEnabled (true),
- myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), myY2GridMajorEnabled( true ),
+ myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), myY2GridMajorEnabled( true ),
myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ),
myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ),
myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ),
myRNormAlgo = new Plot2d_NormalizeAlgorithm(this);
myLNormAlgo = new Plot2d_NormalizeAlgorithm(this);
/* Plot 2d View */
- QVBoxLayout* aLayout = new QVBoxLayout( this );
+ QVBoxLayout* aLayout = new QVBoxLayout( this );
aLayout->setMargin(0);
myPlot = new Plot2d_Plot2d( this );
new Plot2d_ToolTip( this );
aLayout->addWidget( myPlot );
// createActions();
- connect( myPlot, SIGNAL( legendClicked( QwtPlotItem* ) ),
+ connect( myPlot, SIGNAL( legendClicked( QwtPlotItem* ) ),
this, SIGNAL( legendClicked( QwtPlotItem* ) ) );
// IPAL 21465
if (mySecondY)
connect( myPlot->axisWidget( QwtPlot::yRight ), SIGNAL( scaleDivChanged() ),
myPlot, SLOT( onScaleDivChanged() ) );*/
-
+#ifndef NO_SUIT
+ Init();
+#endif
+}
+/*!
+ Destructor
+*/
+Plot2d_ViewFrame::~Plot2d_ViewFrame()
+{
+}
+/*!
+ Performs the initial setup.
+*/
+void Plot2d_ViewFrame::Init()
+{
/* Initial Setup - get from the preferences */
readPreferences();
showLegend( myShowLegend, false );
myPlot->replot();
- if ( parent ) {
- resize( (int)(0.8 * parent->width()), (int)(0.8 * parent->height()) );
+ QWidget* aParent = parentWidget();
+ if ( aParent ) {
+ resize( (int)(0.8 * aParent->width()), (int)(0.8 * aParent->height()) );
}
QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
}
myPlot->canvas()->installEventFilter( this );
}
-/*!
- Destructor
-*/
-Plot2d_ViewFrame::~Plot2d_ViewFrame()
-{
-}
/*!
Gets window's central widget
*/
/*!
Removes all curves from the view
*/
-void Plot2d_ViewFrame::EraseAll()
+void Plot2d_ViewFrame::EraseAll()
{
objectList anObjects;
getObjects( anObjects );
}
myIntermittentSegmentList.clear();
}
-
+
// 3)- Erase all QwtPlotCurve associated with the Plot2d_Curve
int nbCur1 = myQwtPlotCurveList.size();
*/
void Plot2d_ViewFrame::readPreferences()
{
+#ifndef NO_SUIT
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
myCurveType = resMgr->integerValue( "Plot2d", "CurveType", myCurveType );
setNormRMaxMode( resMgr->booleanValue( "Plot2d", "VerNormRMaxMode", myNormRMax ) );
QColor c = resMgr->colorValue( "Plot2d", "DeviationMarkerColor", QColor(255,0,0));
myPlot->setProperty(PLOT2D_DEVIATION_COLOR, c);
- myPlot->setProperty(PLOT2D_DEVIATION_LW,
+ myPlot->setProperty(PLOT2D_DEVIATION_LW,
resMgr->integerValue( "Plot2d", "DeviationMarkerLineWidth", 1));
- myPlot->setProperty(PLOT2D_DEVIATION_TS,
+ myPlot->setProperty(PLOT2D_DEVIATION_TS,
resMgr->integerValue( "Plot2d", "DeviationMarkerTickSize", 2));
-
+#endif
}
/*!
*/
void Plot2d_ViewFrame::writePreferences()
{
+#ifndef NO_SUIT
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
resMgr->setValue( "Plot2d", "CurveType", myCurveType );
resMgr->setValue( "Plot2d", "VerNormLMaxMode", myNormLMax );
resMgr->setValue( "Plot2d", "VerNormRMinMode", myNormRMin );
resMgr->setValue( "Plot2d", "VerNormRMaxMode", myNormRMax );
+#endif
}
/*!
Prints mouse cursor coordinates into string
*/
-QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
+QString Plot2d_ViewFrame::getInfo( const QPoint& pnt )
{
int i;
QwtValueList aTicks;
double majXmark = aTicks[i];
int xmark = myPlot->transform( QwtPlot::xBottom, majXmark );
if ( xmark-2 == pnt.x() ) {
- xCoord = majXmark;
+ xCoord = majXmark;
xFound = true;
break;
}
double minXmark = aTicks[i];
int xmark = myPlot->transform( QwtPlot::xBottom, minXmark );
if ( xmark-2 == pnt.x() ) {
- xCoord = minXmark;
+ xCoord = minXmark;
xFound = true;
break;
}
}
- }
+ }
const QwtScaleDiv* aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft );
aTicks = aYscale->ticks( QwtScaleDiv::MajorTick );
for ( i = 0; i < aTicks.count(); i++ ) {
double majYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yLeft, majYmark );
if ( ymark-2 == pnt.y() ) {
- yCoord = majYmark;
+ yCoord = majYmark;
yFound = true;
break;
}
double minYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yLeft, minYmark );
if ( ymark-2 == pnt.y() ) {
- yCoord = minYmark;
+ yCoord = minYmark;
yFound = true;
break;
}
}
- }
+ }
QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).trimmed();
if ( strX == "-0" )
double majYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yRight, majYmark );
if ( ymark-2 == pnt.y() ) {
- yCoord2 = majYmark;
+ yCoord2 = majYmark;
yFound2 = true;
break;
}
double minYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yRight, minYmark );
if ( ymark-2 == pnt.y() ) {
- yCoord2 = minYmark;
+ yCoord2 = minYmark;
yFound2 = true;
break;
}
}
}
- QString strY2 = QString::number( yFound2 ? yCoord2 :
+ QString strY2 = QString::number( yFound2 ? yCoord2 :
myPlot->invTransform( QwtPlot::yRight, pnt.y() ) ).trimmed();
if ( strY2 == "-0" )
strY2 = "0";
// Total number of curves
// 1)- Construction of a list by component and by system
-
+
// | component 1 | component 2 | ..... | component M |
// | syst1 syst2 ... systN | syst1 syst2 ... systN | ..... | syst1 syst2 ... systN |
QwtScaleWidget *wid = myPlot->axisWidget( QwtPlot::xBottom);
wid->setTitle(" "); // to make the names readable under X axis.
QFont xFont = myPlot->axisFont(QwtPlot::xBottom);
- xFont.setPointSize(8);
+ xFont.setPointSize(8);
myPlot->setAxisFont(QwtPlot::xBottom, xFont);
return ret;
}
QwtSymbol::Style symbolStyle1 = plot2dCurve1->getMarkerStyle();
// We attribute to the current group's curve, the color, the line's kind
// and the marker's kind of the first group's curve
-
+
for (icur=icur1+1; icur<icur1+groupSize; icur++)
{
Plot2d_Curve *plot2dCurve = curveList.at(icur);
updateObject( curve, update );
}
-void Plot2d_ViewFrame::processFiltering(bool update)
+void Plot2d_ViewFrame::processFiltering(bool update)
{
CurveDict aCurves = getCurves();
AlgoPlot2dInputData aLData, aRData;
// Normalization by left Y axis
if (!myNormLMin && !myNormLMax)
myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeNone);
- if(myNormLMin && myNormLMax)
+ if(myNormLMin && myNormLMax)
myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMinMax);
else if(myNormLMin)
myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMin);
// Normalization by right Y axis
if (!myNormRMin && !myNormRMax)
myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeNone);
- if(myNormRMin && myNormRMax)
+ if(myNormRMin && myNormRMax)
myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMinMax);
else if(myNormRMin)
myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMin);
QwtPlotItem* anItem = 0;
if ( !object )
return anItem;
-
+
if ( object->getYAxis() == QwtPlot::yRight )
mySecondY = true;
- // san -- Protection against QwtCurve bug in Qwt 0.4.x:
+ // san -- Protection against QwtCurve bug in Qwt 0.4.x:
// it crashes if switched to X/Y logarithmic mode, when one or more points have
// non-positive X/Y coordinate
if ( myXMode && object->getMinX() <= 0. )
if ( object->isAutoAssign() )
object->autoFill( myPlot );
-
+
if ( hasPlotObject( object ) ) {
processFiltering(update);
updateObject( object, update );
}
}
}
- updateTitles();
+ updateTitles( false );
myPlot->updateYAxisIdentifiers();
- if ( update )
+ if ( update ) {
myPlot->replot();
- if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+ if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase(false);
+ }
return anItem;
}
QwtPlotItem* anObject = getPlotObject( object );
eraseBasicObject(anObject,update);
}
- if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+ if (update) {
+ if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+ }
}
void Plot2d_ViewFrame::eraseBasicObject( QwtPlotItem *object, bool update )
object->hide();
object->detach();
myObjects.remove(object);
- updateTitles();
+ updateTitles(update);
myPlot->updateYAxisIdentifiers();
if ( update )
myPlot->replot();
return;
updatePlotItem(object, anItem );
anItem->setVisible( true );
- if ( update )
+ if ( update ) {
myPlot->replot();
- if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+ if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase(false);
+ }
}
}
bool Plot2d_ViewFrame::isVisible( Plot2d_Object* object ) const
{
return object && hasPlotObject( object ) && getPlotObject( object )->isVisible();
-}
+}
/*!
update legend
void Plot2d_ViewFrame::updateLegend() {
if ( myPlot->getLegend() ) {
ObjectDict::iterator it = myObjects.begin();
- for( ; it != myObjects.end(); ++it )
+ for( ; it != myObjects.end(); ++it )
it.key()->updateLegend(myPlot->getLegend());
}
}
return;
}
- myPlot->setAxisAutoScale( QwtPlot::yLeft );
- myPlot->setAxisAutoScale( QwtPlot::xBottom );
- myPlot->replot();
+ // no need to set auto scaling, it wiil be disabled by setAxisScale() method call
+ // myPlot->setAxisAutoScale( QwtPlot::yLeft );
+ // myPlot->setAxisAutoScale( QwtPlot::xBottom );
+ // myPlot->replot();
double xmin, xmax, y1min, y1max, y2min, y2max;
getFitRangeByCurves(xmin, xmax, y1min, y1max, y2min, y2max);
myPlot->setAxisScale( QwtPlot::yRight, y2min, y2max );
}
myPlot->replot();
- if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
+ if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase(false);
}
/*!
rect.setHeight( MIN_RECT_SIZE );
rect.setTop( rect.top() - MIN_RECT_SIZE/2 );
}
- myPlot->setAxisScale( QwtPlot::yLeft,
- myPlot->invTransform( QwtPlot::yLeft, rect.top() ),
+ myPlot->setAxisScale( QwtPlot::yLeft,
+ myPlot->invTransform( QwtPlot::yLeft, rect.top() ),
myPlot->invTransform( QwtPlot::yLeft, rect.bottom() ) );
if (mySecondY)
- myPlot->setAxisScale( QwtPlot::yRight,
- myPlot->invTransform( QwtPlot::yRight, rect.top() ),
+ myPlot->setAxisScale( QwtPlot::yRight,
+ myPlot->invTransform( QwtPlot::yRight, rect.top() ),
myPlot->invTransform( QwtPlot::yRight, rect.bottom() ) );
- myPlot->setAxisScale( QwtPlot::xBottom,
- myPlot->invTransform( QwtPlot::xBottom, rect.left() ),
+ myPlot->setAxisScale( QwtPlot::xBottom,
+ myPlot->invTransform( QwtPlot::xBottom, rect.left() ),
myPlot->invTransform( QwtPlot::xBottom, rect.right() ) );
myPlot->replot();
if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
if (mySecondY)
myPlot->setAxisScale( QwtPlot::yRight, y2Min, y2Max );
}
- if ( mode == 0 || mode == 1 )
- myPlot->setAxisScale( QwtPlot::xBottom, xMin, xMax );
+ if ( mode == 0 || mode == 1 )
+ myPlot->setAxisScale( QwtPlot::xBottom, xMin, xMax );
myPlot->replot();
if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
}
cols[ "blue-min" ] = color.blue();
}
#endif
-
+
Plot2d_SetupViewDlg* dlg = new Plot2d_SetupViewDlg( this, true, mySecondY );
dlg->setMainTitle( myTitleEnabled, myTitle );
dlg->setXTitle( myXTitleEnabled, myXTitle );
setTitle( dlg->isY2TitleEnabled(), dlg->getY2Title(), Y2Title, false );
// main title
- if( dlg->isMainTitleEnabled() && myTitle != dlg->getMainTitle() )
+ if( dlg->isMainTitleEnabled() && myTitle != dlg->getMainTitle() )
myIsDefTitle = false;
setTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), MainTitle, true );
// curve type
setNormRMaxMode( dlg->getRMaxNormMode() );
}
- myPlot->setProperty(PLOT2D_DEVIATION_COLOR,
+ myPlot->setProperty(PLOT2D_DEVIATION_COLOR,
dlg->getDeviationMarkerCl());
- myPlot->setProperty(PLOT2D_DEVIATION_LW,
+ myPlot->setProperty(PLOT2D_DEVIATION_LW,
dlg->getDeviationMarkerLw());
- myPlot->setProperty(PLOT2D_DEVIATION_TS,
+ myPlot->setProperty(PLOT2D_DEVIATION_TS,
dlg->getDeviationMarkerTs());
// update view
myPlot->replot();
// update preferences
- if ( dlg->isSetAsDefault() )
+ if ( dlg->isSetAsDefault() )
writePreferences();
}
delete dlg;
}
+#ifndef NO_ANALYTICAL_CURVES
/*!
"Analytical Curves" toolbar action slot
*/
c->calculate();
c->setMarkerSize(myMarkerSize);
QwtPlotItem* item = c->plotItem();
-
+
switch( c->getAction() ) {
case Plot2d_AnalyticalCurve::ActAddInView:
if( c->isActive() ) {
}
c->setAction(Plot2d_AnalyticalCurve::ActNothing);
break;
-
+
case Plot2d_AnalyticalCurve::ActUpdateInView:
if(c->isActive()) {
c->updatePlotItem();
item->show();
- } else {
+ } else {
item->hide();
item->detach();
}
-
+
c->setAction(Plot2d_AnalyticalCurve::ActNothing);
- break;
+ break;
case Plot2d_AnalyticalCurve::ActRemoveFromView:
item->hide();
item->detach();
return 0;
#endif
}
+#endif
/*!
"Fit Data" command slot
Plot2d_FitDataDlg* dlg = new Plot2d_FitDataDlg( this, mySecondY );
double xMin,xMax,yMin,yMax,y2Min,y2Max;
getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
-
+
dlg->setRange( xMin, xMax, yMin, yMax, y2Min, y2Max );
if ( dlg->exec() == QDialog::Accepted ) {
int mode = dlg->getRange( xMin, xMax, yMin, yMax, y2Min, y2Max );
fitData(mode,xMin,xMax,yMin,yMax,y2Min,y2Max);
}
delete dlg;
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
/*!
*/
void Plot2d_ViewFrame::onChangeBackground()
{
- QColor selColor = QColorDialog::getColor ( backgroundColor(), this );
+ QColor selColor = QColorDialog::getColor ( backgroundColor(), this );
if ( selColor.isValid() ) {
setBackgroundColor( selColor );
}
\param curveKey - curve id
\param title - new title
*/
-void Plot2d_ViewFrame::setCurveTitle( Plot2d_Curve* curve, const QString& title )
+void Plot2d_ViewFrame::setCurveTitle( Plot2d_Curve* curve, const QString& title )
{
setObjectTitle( curve, title );
}
\param object - object id
\param title - new title
*/
-void Plot2d_ViewFrame::setObjectTitle( Plot2d_Object* object, const QString& title )
-{
+void Plot2d_ViewFrame::setObjectTitle( Plot2d_Object* object, const QString& title )
+{
if ( object && hasPlotObject( object ) )
getPlotObject( object )->setTitle( title );
-}
+}
/*!
Shows/hides legend
QwtLegend* legend = myPlot->legend();
if ( !legend ) {
legend = new QwtLegend( myPlot );
- legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
}
legend->setItemMode( QwtLegend::ClickableItem );
myPlot->insertLegend( legend );
setLegendPos( myLegendPos );
setLegendFont( myLegendFont );
- setLegendFontColor( myLegendColor );
+ setLegendFontColor( myLegendColor );
}
else
myPlot->insertLegend( 0 );
/*!
Sets hor.axis grid parameters
*/
-void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax,
- bool xMinorEnabled, const int xMinorMax,
+void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax,
+ bool xMinorEnabled, const int xMinorMax,
bool update )
{
myXGridMajorEnabled = xMajorEnabled;
/*!
Sets ver.axis grid parameters
*/
-void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax,
+void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax,
bool yMinorEnabled, const int yMinorMax,
- bool y2MajorEnabled, const int y2MajorMax,
- bool y2MinorEnabled, const int y2MinorMax,
+ bool y2MajorEnabled, const int y2MajorMax,
+ bool y2MinorEnabled, const int y2MinorMax,
bool update )
{
myYGridMajorEnabled = yMajorEnabled;
if ( myXMode == mode )
return;
- // san -- Protection against QwtCurve bug in Qwt 0.4.x:
+ // san -- Protection against QwtCurve bug in Qwt 0.4.x:
// it crashes if switched to X/Y logarithmic mode, when one or more points have
// non-positive X/Y coordinate
if ( mode && !isXLogEnabled() ){
+#ifndef NO_SUIT
SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+#else
+ QMessageBox::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+#endif
return;
}
if ( myYMode == mode )
return;
- // san -- Protection against QwtCurve bug in Qwt 0.4.x:
+ // san -- Protection against QwtCurve bug in Qwt 0.4.x:
// it crashes if switched to X/Y logarithmic mode, when one or more points have
// non-positive X/Y coordinate
if ( mode && !isYLogEnabled() ){
+#ifndef NO_SUIT
SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+#else
+ QMessageBox::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+#endif
return;
}
*/
void Plot2d_ViewFrame::plotMousePressed( const QMouseEvent& me )
{
+#ifndef NO_SUIT
Plot2d_ViewWindow* aParent = dynamic_cast<Plot2d_ViewWindow*>(parent());
if (aParent)
aParent->putInfo(getInfo(me.pos()));
+#endif
if ( myOperation == NoOpId )
myOperation = testOperation( me );
if ( myOperation != NoOpId ) {
myPnt = me.pos();
if ( myOperation == GlPanId ) {
myPlot->setAxisScale( QwtPlot::yLeft,
- myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) - myYDistance/2,
+ myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) - myYDistance/2,
myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) + myYDistance/2 );
- myPlot->setAxisScale( QwtPlot::xBottom,
- myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) - myXDistance/2,
+ myPlot->setAxisScale( QwtPlot::xBottom,
+ myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) - myXDistance/2,
myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) + myXDistance/2 );
if (mySecondY)
myPlot->setAxisScale( QwtPlot::yRight,
- myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) - myYDistance2/2,
+ myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) - myYDistance2/2,
myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) + myYDistance2/2 );
myPlot->replot();
}
parent()->eventFilter(this, aEvent);
}
}
- setFocus();
+ setFocus();
}
/*!
Slot, called when user moves mouse
bool aRes = false;
if ( myOperation != NoOpId) {
if ( myOperation == ZoomId ) {
- this->incrementalZoom( dx, dy );
+ this->incrementalZoom( dx, dy );
myPnt = me.pos();
aRes = true;
}
}
}
else {
+#ifndef NO_SUIT
Plot2d_ViewWindow* aParent = dynamic_cast<Plot2d_ViewWindow*>(parent());
if (aParent)
aParent->putInfo(getInfo(me.pos()));
+#endif
}
return aRes;
}
QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
me.pos(), me.globalPos() );
emit contextMenuRequested( &aEvent );
- }
+ }
else {
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) );
myPlot->defaultPicker();
+#ifndef NO_SUIT
Plot2d_ViewWindow* aParent = dynamic_cast<Plot2d_ViewWindow*>(parent());
if (aParent)
aParent->putInfo(tr("INF_READY"));
+#endif
myOperation = NoOpId;
}
/*!
Slot, called when user wheeling mouse
*/
void Plot2d_ViewFrame::wheelEvent(QWheelEvent* event)
-{
+{
QwtPlotLayout* pl = myPlot->plotLayout();
// compute zooming factor
double aDelta = event->delta();
- double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.;
+ double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.;
- bool scaleXBottom = pl->scaleRect(QwtPlot::xBottom).contains( event->pos() ) ||
+ bool scaleXBottom = pl->scaleRect(QwtPlot::xBottom).contains( event->pos() ) ||
pl->canvasRect().contains( event->pos() );
- bool scaleYLeft = pl->scaleRect(QwtPlot::yLeft).contains( event->pos() ) ||
+ bool scaleYLeft = pl->scaleRect(QwtPlot::yLeft).contains( event->pos() ) ||
pl->canvasRect().contains( event->pos() );
- bool scaleYRight = mySecondY && ( pl->scaleRect(QwtPlot::yRight).contains( event->pos() ) ||
+ bool scaleYRight = mySecondY && ( pl->scaleRect(QwtPlot::yRight).contains( event->pos() ) ||
pl->canvasRect().contains( event->pos() ) );
// scale x bottom axis
- if ( scaleXBottom ) {
+ if ( scaleXBottom ) {
QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
if ( xMap.s2() - xMap.s1() > 1.0e-12 || aScale > 1 )
myPlot->setAxisScale( QwtPlot::xBottom, xMap.s1(), xMap.s1() + aScale*(xMap.s2() - xMap.s1()) );
}
-
+
// scale y left axis
if ( scaleYLeft ) {
QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
if ( yMap.s2() - yMap.s1() > 10e-12 || aScale > 1 )
myPlot->setAxisScale( QwtPlot::yRight, yMap.s1(), yMap.s1() + aScale*(yMap.s2() - yMap.s1()) );
}
-
+
// redraw
myPlot->replot();
// update zoomer
if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
// store current mouse position
myPnt = event->pos();
+#ifndef NO_ANALYTICAL_CURVES
// update analytical curves
updateAnalyticalCurves();
+#endif
}
/*!
View operations : Pan view
*/
void Plot2d_ViewFrame::onViewPan()
-{
+{
+ // reset the previous operation
+ myPlot->defaultPicker();
+
QCursor panCursor (Qt::SizeAllCursor);
myPlot->canvas()->setCursor( panCursor );
myOperation = PanId;
/*!
View operations : Zoom view
*/
-void Plot2d_ViewFrame::onViewZoom()
+void Plot2d_ViewFrame::onViewZoom()
{
+ // reset the previous operation
+ myPlot->defaultPicker();
+
QPixmap zoomPixmap (imageZoomCursor);
QCursor zoomCursor (zoomPixmap);
myPlot->canvas()->setCursor( zoomCursor );
myOperation = ZoomId;
}
/*!
- View operations : Fot All
+ View operations : Fit All
*/
-void Plot2d_ViewFrame::onViewFitAll()
-{
+void Plot2d_ViewFrame::onViewFitAll()
+{
fitAll();
+
+ // reset the previous operation
+ myPlot->defaultPicker();
+ myPlot->canvas()->setCursor( QCursor(Qt::CrossCursor) );
+ myOperation = NoOpId;
}
/*!
View operations : Fit Area
*/
-void Plot2d_ViewFrame::onViewFitArea()
+void Plot2d_ViewFrame::onViewFitArea()
{
myPlot->canvas()->setCursor( QCursor( Qt::PointingHandCursor ) );
myOperation = FitAreaId;
/*!
View operations : Global panning
*/
-void Plot2d_ViewFrame::onViewGlobalPan()
+void Plot2d_ViewFrame::onViewGlobalPan()
{
+ // reset the previous operation
+ myPlot->defaultPicker();
+
QPixmap globalPanPixmap (imageCrossCursor);
QCursor glPanCursor (globalPanPixmap);
myPlot->canvas()->setCursor( glPanCursor );
QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
myYDistance2 = yMap2.s2() - yMap2.s1();
}
- fitAll();
+ // don't make fit all
+ // fitAll();
myOperation = GlPanId;
}
setAxisAutoScale( QwtPlot::yLeft );
setAxisAutoScale( QwtPlot::yRight );
setAxisAutoScale( QwtPlot::xBottom );
-
+
myScaleDraw = NULL;
// grid
myGrid = new QwtPlotGrid();
}
/*!
- Recalculates and redraws Plot 2d view
+ Recalculates and redraws Plot 2d view
*/
void Plot2d_Plot2d::replot()
{
enableAxis( QwtPlot::yRight, enableYRight );
updateLayout(); // to fix bug(?) of Qwt - view is not updated when title is changed
- QwtPlot::replot();
+ QwtPlot::replot();
}
/*!
{
#if QWT_VERSION < 0x040200
return d_legend;
-#else
+#else
return legend(); /* mpv: porting to the Qwt 4.2.0 */
#endif
}
aPlotMarker->setYValue(Y);
//
aPlotMarker->attach(this);
-
+
// Associate a tooltip with the point's marker
// PB: how to obtain a tooltip with a rectangular frame ?
//QwtText tooltip ("X=" + QString::number(X) + " Y=" + QString::number(Y) );
text.setBackgroundBrush( QBrush(tooltipColor)); //, Qt::SolidPattern));
//
if ( picker ) {
- picker->pMarkers.append( aPlotMarker);
+ picker->pMarkers.append( aPlotMarker);
picker->pMarkersToolTip[ aPlotMarker] = text;
}
return aPlotMarker;
myLegendPos = vf->myLegendPos;
myMarkerSize = vf->myMarkerSize;
myBackground = vf->myBackground;
- myTitle = vf->myTitle;
+ myTitle = vf->myTitle;
myXTitle = vf->myXTitle;
myYTitle = vf->myYTitle;
myY2Title = vf->myY2Title;
Updates titles according to curves
*/
#define BRACKETIZE(x) QString( "[ " ) + x + QString( " ]" )
-void Plot2d_ViewFrame::updateTitles()
+void Plot2d_ViewFrame::updateTitles( const bool update )
{
ObjectDict::iterator it = myObjects.begin();
QStringList aXTitles;
QString yTitle = anObject->getVerTitle().trimmed();
QString xUnits = anObject->getHorUnits().trimmed();
QString yUnits = anObject->getVerUnits().trimmed();
-
+
if ( anObject->getYAxis() == QwtPlot::yLeft ) {
if ( !aYTitles.contains( yTitle ) )
aYTitles.append( yTitle );
if ( !y2Title.isEmpty() && !y2Units.isEmpty() )
y2Title += " ";
- setTitle( myXTitleEnabled, xTitle + xUnits, XTitle, true );
- setTitle( myYTitleEnabled, yTitle + yUnits, YTitle, true );
+ setTitle( myXTitleEnabled, xTitle + xUnits, XTitle, false );
+ setTitle( myYTitleEnabled, yTitle + yUnits, YTitle, false );
if ( mySecondY )
- setTitle( myY2TitleEnabled, y2Title + y2Units, Y2Title, true );
- if( myIsDefTitle )
- setTitle( true, aTables.join("; "), MainTitle, true );
+ setTitle( myY2TitleEnabled, y2Title + y2Units, Y2Title, false );
+ if( myIsDefTitle )
+ setTitle( true, aTables.join("; "), MainTitle, false );
+
+ // do update if necessary
+ if ( update ) {
+ myPlot->replot();
+ }
}
/*!
getFitRanges( xmin, xmax, ymin, ymax, y2min, y2max );
QString retStr;
//Store font in the visual parameters string as:
- //
+ //
// ...*FontFamily|FontSize|B|I|U|r:g:b*...
-
+
retStr.sprintf( "%d*%d*%d*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%s|%i|%i|%i|%i|%i:%i:%i",
myXMode, myYMode, mySecondY, xmin, xmax, ymin, ymax, y2min, y2max,
qPrintable(myLegendFont.family()), myLegendFont.pointSize(),myLegendFont.bold(),
myLegendFont.italic(), myLegendFont.underline(),myLegendColor.red(),
myLegendColor.green(), myLegendColor.blue());
-
+
//store all Analytical curves
//store each curve in the following format
// ...*Name|isActive|Expresion|NbInervals|isAutoAssign[|MarkerType|LineType|LineWidth|r:g:b]
// parameters in the [ ] is optional in case if isAutoAssign == true
AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
Plot2d_AnalyticalCurve* c = 0;
- bool isAuto;
+ bool isAuto;
for( ; it != myAnalyticalCurves.end(); it++) {
c = (*it);
if(!c) continue;
}
}
retStr += QString( "*%1" ).arg( Qtx::colorToString( backgroundColor() ) );
- return retStr;
+ return retStr;
*/
}
setTitle( myY2TitleEnabled, myY2Title, Y2Title, false );
setHorScaleMode( myXMode, /*update=*/false );
setVerScaleMode( myYMode, /*update=*/false );
-
+
if (mySecondY) {
QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
myYDistance2 = yMap2.s2() - yMap2.s1();
}
-
+
fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );
fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );
}
colorList[2].toInt());
setLegendFontColor( myLegendColor );
}
- }
+ }
}
+#ifndef NO_ANALYTICAL_CURVES
//Restore all Analytical curves
int startCurveIndex = 10;
if( paramsLst.size() >= startCurveIndex+1 ) {
}
myPlot->replot();
}
+#endif
}
/*!
aWriter.writeEndElement();
aWriter.writeEndElement();
+#ifndef NO_ANALYTICAL_CURVES
//AnalyticalCurve
- aWriter.writeStartElement("AnalyticalCurves");
+ aWriter.writeStartElement("AnalyticalCurves");
AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
Plot2d_AnalyticalCurve* c = 0;
- bool isAuto;
+ bool isAuto;
int id = 1;
for( ; it != myAnalyticalCurves.end(); it++) {
c = (*it);
id++;
}
aWriter.writeEndElement(); //AnalyticalCurve
+#endif
//Background
- aWriter.writeStartElement(QString("Background").arg(id));
- aWriter.writeStartElement(QString("BackgroundColor").arg(id));
+ aWriter.writeStartElement(QString("Background"));
+ aWriter.writeStartElement(QString("BackgroundColor"));
aWriter.writeAttribute("R", QString("").sprintf("%d",backgroundColor().red()));
aWriter.writeAttribute("G", QString("").sprintf("%d",backgroundColor().green()));
aWriter.writeAttribute("B", QString("").sprintf("%d",backgroundColor().blue()));
setLegendFontColor( myLegendColor );
setLegendFont(myLegendFont);
} else if(aReader.name().toString().indexOf("AnalyticalCurve_") >= 0) {
+#ifndef NO_ANALYTICAL_CURVES
Plot2d_AnalyticalCurve* c = new Plot2d_AnalyticalCurve();
c->setName(aAttr.value("Name").toString());
c->setActive((bool)aAttr.value("IsActive").toString().toInt());
if( !c->isAutoAssign() ) {
c->setMarker((Plot2d::MarkerType)aAttr.value("Marker").toString().toInt());
c->setLine((Plot2d::LineType)aAttr.value("Line").toString().toInt());
- c->setLineWidth(aAttr.value("LineWidth").toString().toInt());
+ c->setLineWidth(aAttr.value("LineWidth").toString().toInt());
c->setColor(QColor(aAttr.value("R").toString().toInt(),
aAttr.value("G").toString().toInt(),
aAttr.value("B").toString().toInt()));
}
addAnalyticalCurve(c);
updateAnalyticalCurve(c);
+#endif
} else if(aReader.name().toString() == "BackgroundColor") {
setBackgroundColor(QColor(aAttr.value("R").toString().toInt(),
aAttr.value("G").toString().toInt(),
if (mySecondY)
setTitle( myY2TitleEnabled, myY2Title, Y2Title, false );
setHorScaleMode( myXMode, /*update=*/false );
- setVerScaleMode( myYMode, /*update=*/false );
+ setVerScaleMode( myYMode, /*update=*/false );
if (mySecondY) {
QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
myYDistance2 = yMap2.s2() - yMap2.s1();
- }
+ }
setNormLMinMode(leftMin);
setNormLMaxMode(leftMax);
setNormRMinMode(rightMin);
showLegend( myShowLegend, false );
- fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );
+ fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max );
return true;
}
void Plot2d_ViewFrame::incrementalPan( const int incrX, const int incrY ) {
QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
-
- myPlot->setAxisScale( QwtPlot::yLeft,
- myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s1() )-incrY ),
+
+ myPlot->setAxisScale( QwtPlot::yLeft,
+ myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s1() )-incrY ),
myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s2() )-incrY ) );
- myPlot->setAxisScale( QwtPlot::xBottom,
+ myPlot->setAxisScale( QwtPlot::xBottom,
myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s1() )-incrX ),
- myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s2() )-incrX ) );
+ myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s2() )-incrX ) );
if (mySecondY) {
QwtScaleMap y2Map = myPlot->canvasMap( QwtPlot::yRight );
myPlot->setAxisScale( QwtPlot::yRight,
- myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.s1() )-incrY ),
+ myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.s1() )-incrY ),
myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.s2() )-incrY ) );
}
myPlot->replot();
void Plot2d_ViewFrame::incrementalZoom( const int incrX, const int incrY ) {
QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
-
- myPlot->setAxisScale( QwtPlot::yLeft, yMap.s1(),
+
+ myPlot->setAxisScale( QwtPlot::yLeft, yMap.s1(),
myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.s2() ) + incrY ) );
- myPlot->setAxisScale( QwtPlot::xBottom, xMap.s1(),
+ myPlot->setAxisScale( QwtPlot::xBottom, xMap.s1(),
myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.s2() ) - incrX ) );
if (mySecondY) {
QwtScaleMap y2Map = myPlot->canvasMap( QwtPlot::yRight );
}
/*
- Update plot item
+ Update plot item
*/
void Plot2d_ViewFrame::updatePlotItem(Plot2d_Object* theObject, QwtPlotItem* theItem) {
theObject->updatePlotItem( theItem );
continue;
double d;
int i = aCurve->closestPoint( p, &d );
- if ( index > -1 && ( distance < 0 || d < distance ) ) {
+ if ( i > -1 && ( distance < 0 || d < distance ) ) {
pCurve = it.value();
distance = d;
index = i;
return pCurve;
}
+#ifndef NO_ANALYTICAL_CURVES
/*!
\brief Deselect all analytical curves.
*/
c->setSelected(false);
}
}
+#endif
/*!
\brief Deselect all objects, except analytical curves.
void Plot2d_ViewFrame::onPanLeft()
{
this->incrementalPan( -INCREMENT_FOR_OP, 0 );
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
/*!
void Plot2d_ViewFrame::onPanRight()
{
this->incrementalPan( INCREMENT_FOR_OP, 0 );
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
/*!
void Plot2d_ViewFrame::onPanUp()
{
this->incrementalPan( 0, -INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
/*!
void Plot2d_ViewFrame::onPanDown()
{
this->incrementalPan( 0, INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
/*!
void Plot2d_ViewFrame::onZoomIn()
{
this->incrementalZoom( INCREMENT_FOR_OP, INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
/*!
void Plot2d_ViewFrame::onZoomOut()
{
this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP );
+#ifndef NO_ANALYTICAL_CURVES
updateAnalyticalCurves();
+#endif
}
/*!
*
*/
Plot2d_Object* Plot2d_ViewFrame::getPlotObject( QwtPlotItem* plotItem ) const {
-
+
ObjectDict::const_iterator it = myObjects.begin();
for( ; it != myObjects.end(); ++it ) {
if ( it.key() == plotItem ) {
double aDist = fabs(map().s2()-map().s1())/5;
int precision = 0;
while (aDist < 1 ) {
- precision++;
- aDist *= 10.;
+ precision++;
+ aDist *= 10.;
}
if ( precision > 0 && value > 0 )
return QLocale::system().toString( value,'f', precision );
for (int i = 0; i < myTicks.size(); i++)
{
- drawLabel( painter, myTicks[i]);
- }
-
+ drawLabel( painter, myTicks[i]);
+ }
+
//std::cout << "Ok for Plot2d_AxisScaleDraw::draw()" << std::endl;
}
if (myLowerBound != -1 && myUpperBound != -1)
aScaleDiv->setInterval(myLowerBound, myUpperBound);
-
+
//for (int i = 0; i < myTicks.size(); i++){
// QPoint p = labelPosition( i );
// qDebug() << i<< ") applyTicks -> LABEL" <<p;
p += QPoint(0, DEVICE_BY);
QFont prevf = painter->font();
//QColor prevc = (painter->pen()).color();
-
+
QFont devicef( DEVICE_FONT, DEVICE_FONT_SIZE, QFont::Bold);
//
//painter->setPen( QColor("blue") );
QwtScaleDraw::drawLabel( painter, value );
}
}
-
+
void Plot2d_AxisScaleDraw::drawTick( QPainter* painter, double value, int len) const
{
if ( myLabelX.contains(value) )
{
QwtScaleDraw::drawTick( painter, value, len);
- }
+ }
}
/* Management of tooltips associated with markers for curves points or others points
*/
const double Plot2d_QwtPlotPicker::BOUND_HV_SIZE = 0.2;
-
+
Plot2d_QwtPlotPicker::Plot2d_QwtPlotPicker( int xAxis,
int yAxis,
int selectionFlags,
canvas) // of drawing zone QwtPlot
{
}
-
+
Plot2d_QwtPlotPicker::Plot2d_QwtPlotPicker( int xAxis,
int yAxis,
QwtPlotCanvas *canvas)
}
}
}
- return QwtText();
+ return QwtText();
}