From bd437caa83b965d4489cc168b1fbf03708211c69 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 22 Jun 2021 17:40:37 +0300 Subject: [PATCH] GUITHARE issue 20930: Add possibility to change time axis unity. --- src/Plot2d/Plot2d_Curve.cxx | 4 ++-- src/Plot2d/Plot2d_Curve.h | 2 +- src/Plot2d/Plot2d_ViewFrame.cxx | 29 ++++++++++++++++++++++++----- src/Plot2d/Plot2d_ViewFrame.h | 11 ++++++++--- src/Plot3d/Plot3d_Actor.cxx | 20 ++++++++++++++++++++ src/Plot3d/Plot3d_Actor.h | 5 +++++ 6 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index c1807dbe6..427680c88 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -260,12 +260,12 @@ void Plot2d_Curve::setData( const double* hData, const double* vData, /*! Gets curve's data : abscissas of points */ -double* Plot2d_Curve::horData() const +double* Plot2d_Curve::horData( const double theMultiplier ) const { int aNPoints = nbPoints(); double* aX = new double[aNPoints]; for (int i = 0; i < aNPoints; i++) { - aX[i] = myPoints[i].x; + aX[i] = myPoints[i].x * theMultiplier; } return aX; } diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h index 48ecfb1ff..e1ab97e75 100755 --- a/src/Plot2d/Plot2d_Curve.h +++ b/src/Plot2d/Plot2d_Curve.h @@ -75,7 +75,7 @@ public: void setData( const double*, const double*, long, const QStringList& = QStringList(), const int* theColorIds = 0 ); - double* horData() const; + double* horData( const double ) const; double* verData() const; int* colorData() const; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 4ffc36b64..ccba2772a 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -180,7 +180,10 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ), myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ), myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ), - myXMode( 0 ), myYMode( 0 ), mySecondY( false ), myKeepCurrentRange( false ), + myXMode( 0 ), myYMode( 0 ), + myXDistance( 0 ), myYDistance( 0 ), myYDistance2( 0 ), + mySecondY( false ), myKeepCurrentRange( false ), + myXMultiplier( 1 ), myTitleAutoUpdate( true ), myXTitleAutoUpdate( true ), myYTitleAutoUpdate( true ), myTitleChangedByUser( false ), myXTitleChangedByUser( false ), myYTitleChangedByUser( false ), myY2TitleChangedByUser( false ), myIsTimeColorization( false ), myTimePosition( -1 ), myInactiveColor( Qt::gray ) @@ -309,7 +312,7 @@ void Plot2d_ViewFrame::setSecondY( const bool& theSecondY ) /*! Get second Y */ -bool Plot2d_ViewFrame::getSecondY() +bool Plot2d_ViewFrame::getSecondY() const { return mySecondY; } @@ -325,11 +328,27 @@ void Plot2d_ViewFrame::setKeepCurrentRange( const bool& theKeepCurrentRange ) /*! Get flag which indicate keep current range or not */ -bool Plot2d_ViewFrame::getKeepCurrentRange() +bool Plot2d_ViewFrame::getKeepCurrentRange() const { return myKeepCurrentRange; } +/*! + Set X axis multiplier +*/ +void Plot2d_ViewFrame::setXMultiplier( const double theXMultiplier ) +{ + myXMultiplier = theXMultiplier; +} + +/*! + Get X axis multiplier +*/ +double Plot2d_ViewFrame::getXMultiplier() const +{ + return myXMultiplier; +} + /*! Erase presentation */ @@ -674,7 +693,7 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) curve->buildSymbolsColorMap( myPlot, MAX_ATTEMPTS ); } setCurveType( aPCurve, myCurveType ); - aPCurve->setData( curve->horData(), curve->verData(), curve->nbPoints() ); + aPCurve->setData( curve->horData( 1.0 / myXMultiplier ), curve->verData(), curve->nbPoints() ); aPCurve->setYAxis( curve->getYAxis() ); aPCurve->setSymbolsColorData( curve->colorData(), curve->nbPoints() ); aPCurve->setSymbolsColorMap( curve->getColorMap() ); @@ -768,7 +787,7 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) QBrush( curve->getColor() ), QPen( curve->getColor(), 1 ), // width's set to 1 for correct printing QSize( myMarkerSize, myMarkerSize ) ) ); - aPCurve->setData( curve->horData(), curve->verData(), curve->nbPoints() ); + aPCurve->setData( curve->horData( 1.0 / myXMultiplier ), curve->verData(), curve->nbPoints() ); Plot2d_PlotCurve* aPlot2dCurve = dynamic_cast< Plot2d_PlotCurve* >( aPCurve ); if ( aPlot2dCurve ) { diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 20e633cb7..f0a814c21 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -130,10 +130,13 @@ public: QString getTitle( ObjectType type ) const; void setSecondY( const bool& theSecondY ); - bool getSecondY(); + bool getSecondY() const; - bool getKeepCurrentRange(); void setKeepCurrentRange( const bool& theKeepCurrentRange ); + bool getKeepCurrentRange() const; + + void setXMultiplier( const double theXMultiplier ); + double getXMultiplier() const; bool isTitleChangedByUser( const ObjectType type ); void forgetLocalUserChanges( const ObjectType type ); @@ -244,7 +247,9 @@ protected: double myXDistance, myYDistance, myYDistance2; bool mySecondY; bool myKeepCurrentRange; - + + double myXMultiplier; // 0.001 for ms, 1 for seconds, 60 for minutes, 3600 for hours + bool myTitleAutoUpdate, myXTitleAutoUpdate, myYTitleAutoUpdate; bool myTitleChangedByUser, myXTitleChangedByUser, myYTitleChangedByUser, myY2TitleChangedByUser; diff --git a/src/Plot3d/Plot3d_Actor.cxx b/src/Plot3d/Plot3d_Actor.cxx index f79a9dcaa..21a525249 100644 --- a/src/Plot3d/Plot3d_Actor.cxx +++ b/src/Plot3d/Plot3d_Actor.cxx @@ -90,6 +90,8 @@ Plot3d_Actor::Plot3d_Actor() myStartPoint = 0; myEndPoint = 0; + myTimeUnit = -1; + // Scalar bar myToDisplayScalarBar = false; @@ -699,3 +701,21 @@ void Plot3d_Actor::GetRealBounds( double theBounds[6] ) const theBounds[4] = myRealBounds[4]; theBounds[5] = myRealBounds[5]; } + +//============================================================================= +// Function : SetTimeUnit +// Purpose : +//============================================================================= +void Plot3d_Actor::SetTimeUnit( const int theTimeUnit ) +{ + myTimeUnit = theTimeUnit; +} + +//============================================================================= +// Function : GetTimeUnit +// Purpose : +//============================================================================= +int Plot3d_Actor::GetTimeUnit() const +{ + return myTimeUnit; +} diff --git a/src/Plot3d/Plot3d_Actor.h b/src/Plot3d/Plot3d_Actor.h index 40fac912a..95a0a469f 100644 --- a/src/Plot3d/Plot3d_Actor.h +++ b/src/Plot3d/Plot3d_Actor.h @@ -115,6 +115,9 @@ public: void GetRealBounds( double theBounds[6] ) const; + void SetTimeUnit( const int ); + int GetTimeUnit() const; + protected: int myNX; int myNY; @@ -151,6 +154,8 @@ protected: int myEndPoint; double myRealBounds[6]; + + int myTimeUnit; // defined and used in GUITHARE }; #endif -- 2.39.2