-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <qwt_plot_zoomer.h>
#include <qwt_curve_fitter.h>
#include <qwt_plot_renderer.h>
+#include <qwt_legend.h>
+#include <qwt_scale_widget.h>
#include <stdlib.h>
#include <limits>
-#include <qprinter.h>
-
-#include <qwt_legend.h>
-#include <qwt_scale_widget.h>
#define DEFAULT_LINE_WIDTH 0 // (default) line width
#define DEFAULT_MARKER_SIZE 9 // default marker size
icur2 = icur1 + groupSize -1;
// For all curves in one group
- double XgroupMin, XgroupMax;
- double YgroupMin, YgroupMax;
+ double XgroupMin = 0., XgroupMax = 0.;
+ double YgroupMin = 0., YgroupMax = 0.;
// For one curve
- double XcurveMin, XcurveMax;
- double YcurveMin, YcurveMax;
+ double XcurveMin = 0., XcurveMax = 0.;
+ double YcurveMin = 0., YcurveMax = 0.;
double *Xval;
double *Yval;
int nbPoints;
int lineWidth,
QColor & lineColor,
QwtSymbol::Style markerKind,
- Plot2d_QwtPlotPicker* picker,
+ Plot2d_QwtPlotPicker* /*picker*/,
bool toDraw,
bool displayLegend)
{
aPCurve->setSamples( X, Y, nbPoint);
aPCurve->setPen( QPen( lineColor, lineWidth, lineKind));
- QwtSymbol* aSymbol;
+ QwtSymbol* aSymbol = new QwtSymbol();
aSymbol->setStyle( markerKind );
aPCurve->setSymbol( aSymbol );
*/
int Plot2d_ViewFrame::testOperation( const QMouseEvent& me )
{
- int btn = me.button() | me.modifiers();
- const int zoomBtn = Qt::ControlModifier | Qt::LeftButton;
- const int panBtn = Qt::ControlModifier | Qt::MidButton;
- const int fitBtn = Qt::ControlModifier | Qt::RightButton;
+ int btn = (int)me.button() | (int)me.modifiers();
+ const int zoomBtn = (int)Qt::ControlModifier | (int)Qt::LeftButton;
+ const int panBtn = (int)Qt::ControlModifier | (int)Qt::MidButton;
+ const int fitBtn = (int)Qt::ControlModifier | (int)Qt::RightButton;
int op = NoOpId;
if ( btn == zoomBtn ) {
*/
void Plot2d_ViewFrame::onAnalyticalCurve()
{
-#ifndef DISABLE_PYCONSOLE
Plot2d_AnalyticalCurveDlg dlg( this, this );
dlg.exec();
updateAnalyticalCurves();
-#endif
}
void Plot2d_ViewFrame::addAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
{
-#ifndef DISABLE_PYCONSOLE
- myAnalyticalCurves.append(theCurve);
-#endif
+ myAnalyticalCurves.append(theCurve);
}
void Plot2d_ViewFrame::removeAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
{
-#ifndef DISABLE_PYCONSOLE
- theCurve->setAction(Plot2d_AnalyticalCurve::ActRemoveFromView);
-#endif
+ theCurve->setAction(Plot2d_AnalyticalCurve::ActRemoveFromView);
}
/*
*/
void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool updateView)
{
-#ifndef DISABLE_PYCONSOLE
if(!c) return;
QwtScaleDiv div = myPlot->axisScaleDiv(QwtPlot::xBottom);
c->setRangeBegin(div.lowerBound());
case Plot2d_AnalyticalCurve::ActRemoveFromView:
item->hide();
item->detach();
- myAnalyticalCurves.removeAll(c);
- delete c;
break;
}
if(updateView)
myPlot->replot();
-#endif
}
/*
*/
void Plot2d_ViewFrame::updateAnalyticalCurves()
{
-#ifndef DISABLE_PYCONSOLE
AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
+ AnalyticalCurveList toDelete;
for( ; it != myAnalyticalCurves.end(); it++) {
- updateAnalyticalCurve(*it);
+ Plot2d_AnalyticalCurve* c = (*it);
+ updateAnalyticalCurve(c);
+ if(c && c->getAction() == Plot2d_AnalyticalCurve::ActRemoveFromView)
+ toDelete.push_back(c);
+ }
+ it = toDelete.begin();
+ for( ; it != toDelete.end(); it++) {
+ Plot2d_AnalyticalCurve* c = (*it);
+ myAnalyticalCurves.removeAll(c);
+ delete c;
+ c = NULL;
}
myPlot->replot();
-#endif
}
/*!
*/
AnalyticalCurveList Plot2d_ViewFrame::getAnalyticalCurves() const
{
- return myAnalyticalCurves;
+ return myAnalyticalCurves ;
}
/*!
Get analytical curve by plot item.
*/
Plot2d_AnalyticalCurve* Plot2d_ViewFrame::getAnalyticalCurve(QwtPlotItem * theItem) {
-#ifndef DISABLE_PYCONSOLE
AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
for( ; it != myAnalyticalCurves.end(); it++) {
- if((*it)->plotItem() == theItem);
- return (*it);
+ if((*it)->plotItem() == theItem)
+ return (*it);
}
return 0;
-#endif
}
#endif
if ( crv )
setCurveType( crv, myCurveType );
}
+ for(int i=0 ; i < myAnalyticalCurves.count(); i++) {
+ QwtPlotCurve* aPCurve = dynamic_cast<QwtPlotCurve*>( myAnalyticalCurves[i]->plotItem() );
+ Plot2d_AnalyticalCurve* aCurve = dynamic_cast<Plot2d_AnalyticalCurve*>( myAnalyticalCurves[i] );
+ if ( aPCurve && aCurve ) {
+ setCurveType( aPCurve, myCurveType );
+ }
+ }
if ( update )
myPlot->replot();
emit vpCurveChanged();
// non-positive X/Y coordinate
if ( mode && !isXLogEnabled() ){
#ifndef NO_SUIT
- SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
#else
- QMessageBox::warning(this, tr("WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
+ QMessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_XLOG_NOT_ALLOWED"));
#endif
return;
}
// non-positive X/Y coordinate
if ( mode && !isYLogEnabled() ){
#ifndef NO_SUIT
- SUIT_MessageBox::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
#else
- QMessageBox::warning(this, tr("WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
+ QMessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_YLOG_NOT_ALLOWED"));
#endif
return;
}
}
}
else {
- int btn = me.button() | me.modifiers();
+ int btn = (int)me.button() | (int)me.modifiers();
if (btn == Qt::RightButton) {
QMouseEvent* aEvent = new QMouseEvent(QEvent::MouseButtonPress,
me.pos(), me.button(), me.buttons(), me.modifiers() );
/*!
Sets curve type
*/
-void Plot2d_ViewFrame::setCurveType( QwtPlotCurve* curve, int curveType )
+void Plot2d_ViewFrame::setCurveType( QwtPlotCurve* curve, int /*curveType*/ )
{
if ( !curve )
return;
QwtPlotGrid* Plot2d_Plot2d::grid() const
{
return myGrid;
-};
+}
QwtPlotZoomer* Plot2d_Plot2d::zoomer() const
{
QList<double> allTicks;
double devXmin, devXmax; // X interval of a system
- double gapXmin, gapXmax; // X interval between two systems
+ double gapXmin = 0., gapXmax = 0.; // X interval between two systems
double devLabPos; // Label's position of a system
double segmentPos; // Position of the vertical segment between current system and the next
aWriter.writeAttribute("Name",c->getName());
aWriter.writeAttribute("IsActive", QString("").sprintf("%d", c->isActive()));
aWriter.writeAttribute("Expression", c->getExpression());
- aWriter.writeAttribute("NbIntervals", QString("").sprintf("%d", c->getNbIntervals()));
+ aWriter.writeAttribute("NbIntervals", QString("").sprintf("%ld", c->getNbIntervals()));
aWriter.writeAttribute("isAuto", QString("").sprintf("%d",isAuto));
if(!isAuto) {
aWriter.writeAttribute("Marker", QString("").sprintf("%d",(int)c->getMarker()));
*/
bool Plot2d_ViewFrame::setXmlVisualParameters(const QString& parameters) {
QXmlStreamReader aReader(parameters);
- double xmin, xmax, ymin, ymax, y2min, y2max;
+ double xmin = 0., xmax = 0., ymin = 0., ymax = 0., y2min = 0., y2max = 0.;
bool leftMin,leftMax,rightMin,rightMax;
leftMin = leftMax = rightMin = rightMax = false;
while(!aReader.atEnd()) {
}
+double Plot2d_AxisScaleDraw::extent( const QFont &font ) const
+{
+ QFontMetrics fm( font );
+ return QwtScaleDraw::extent( font ) + fm.height() * 2;
+}
+
QwtText Plot2d_AxisScaleDraw::label( double value) const
{
if (myLabelX.contains(value))