void Plot2d_SetupCurvesDlg::SetParameters( const QVector< int >& theMarker,
const QVector< QString >& theText,
const QVector< QColor >& theColor,
- const QVector< int >& theNbMarkers )
+ const QVector< double >& theNbMarkers )
{
int nbRows = qMax( qMax( theMarker.size(), theText.size()),
qMax( theColor.size(), theNbMarkers.size() ) );
void Plot2d_SetupCurvesDlg::GetParameters( QVector< int >& theMarkers,
QVector< QString >& theTexts,
QVector< QColor >& theColors,
- QVector< int >& theNbMarkers ) const
+ QVector< double >& theNbMarkers ) const
{
int nbRows = myTable->rowCount();
it = myTable->item( i, NB_MARKERS_COL );
QString aStr = it ? it->text() : "";
bool isOk = false;
- int nbMarkers = aStr.toInt( &isOk );
+ double nbMarkers = aStr.toDouble( &isOk );
if ( isOk )
theNbMarkers[ i ] = nbMarkers;
else
QTableWidgetItem* it = myTable->item( i, NB_MARKERS_COL );
QString aStr = it ? it->text() : "";
bool isOk = false;
- int nbMarkers = aStr.toInt( &isOk );
+ double nbMarkers = aStr.toDouble( &isOk );
if ( !isOk || nbMarkers<= 0 )
{
SUIT_MessageBox::information( (QWidget*)this, tr( "PLOT2D_INSUFFICIENT_DATA" ),
QVector< int > aMarkers( nbCurves );
QVector< QString > aTexts( nbCurves );
QVector< QColor > aColors( nbCurves );
- QVector< int > nbMarkers( nbCurves );
+ QVector< double > nbMarkers( nbCurves );
QList< Plot2d_Curve* > aCurves;
if ( aText.isEmpty() )
aText = aCurve->getVerTitle();
QColor aColor = aCurve->getColor();
- int nbMarker = aCurve->getNbMarkers();
+ double nbMarker = aCurve->getNbMarkers();
aMarkers[ i ] = aMarkerType;
aTexts[ i ] = aText;
isHorTitle = false;
}
QColor anOldColor = aCurve->getColor();
- int anOldNbMarker = aCurve->getNbMarkers();
+ double anOldNbMarker = aCurve->getNbMarkers();
// new values
Plot2d::MarkerType aMarker = (Plot2d::MarkerType)aMarkers[ i ];
QString aText = aTexts[ i ];
QColor aColor = aColors[ i ];
- int nbMarker = nbMarkers[ i ];
+ double nbMarker = nbMarkers[ i ];
bool toUpdate = false;
(for example) then markers are displayed for steps and two markers are
displayed between side by side steps.
*/
-void Plot2d_PlotCurve::setNbMarkers( const int theNbMarkers )
+void Plot2d_PlotCurve::setNbMarkers( const double theNbMarkers )
{
myNbMarkers = theNbMarkers;
}
(for example) then markers are displayed for steps and two markers are
displayed between side by side steps.
*/
-int Plot2d_PlotCurve::nbMarkers() const
+double Plot2d_PlotCurve::nbMarkers() const
{
return myNbMarkers;
}
}
else
{
+ double aTail = 0.0;
for ( int i = from; i <= to; i++ )
{
- const int u = xMap.transform(x(i));
- const int v = yMap.transform(y(i));
+ double u1 = xMap.transform( x( i ) );
+ double v1 = yMap.transform( y( i ) );
- rect.moveCenter( QPoint( u, v ) );
- symbol.draw( p, rect );
+ if ( i == to && myNbMarkers > 0 )
+ {
+ rect.moveCenter( QPoint( u1, v1 ) );
+ symbol.draw( p, rect );
+ }
- // draw markers between current and previous step
- if ( myNbMarkers > 1 && i >= 1 )
+ if ( i > from && myNbMarkers > 0 )
{
- int u_1 = xMap.transform( x( i - 1 ) );
- int v_1 = yMap.transform( y( i - 1 ) );
+ double u0 = xMap.transform( x( i - 1 ) );
+ double v0 = yMap.transform( y( i - 1 ) );
- if ( u_1 == u )
+ if ( u1 == u0 && v1 == v0 )
continue;
- double k = ( (double)( v_1 - v ) ) / ( u_1 - u );
- double b = v - k * u;
- double step = ( (double)( u - u_1 ) ) / myNbMarkers;
- for ( int ind = 1; ind < myNbMarkers; ind++ )
- {
- int X = (int)( u_1 + step * ind );
- int Y = (int)( k * X + b );
+ double dX = ( u1 - u0 ) / myNbMarkers;
+ double dY = ( v1 - v0 ) / myNbMarkers;
+
+ double u = u0 + dX * aTail;
+ double v = v0 + dY * aTail;
- rect.moveCenter( QPoint( X, Y ) );
+ while ( aTail >= 0 && u <= u1 && v <= v1 )
+ {
+ rect.moveCenter( QPoint( u, v ) );
symbol.draw( p, rect );
+
+ u += dX;
+ v += dY;
+
+ aTail += 1;
}
+
+ aTail -= myNbMarkers;
}
}
}
(for example) then markers are displayed for steps and two markers are
displayed between side by side steps.
*/
-bool Plot2d_Plot2d::setCurveNbMarkers( Plot2d_Curve* curve, const int nb )
+bool Plot2d_Plot2d::setCurveNbMarkers( Plot2d_Curve* curve, const double nb )
{
Plot2d_PlotCurve* aPlotCurve =
dynamic_cast<Plot2d_PlotCurve*>( myCurves.findKey( curve ) );
(for example) then markers are displayed for steps and two markers are
displayed between side by side steps.
*/
-int Plot2d_Plot2d::curveNbMarkers( Plot2d_Curve* curve ) const
+double Plot2d_Plot2d::curveNbMarkers( Plot2d_Curve* curve ) const
{
Plot2d_PlotCurve* aPlotCurve =
dynamic_cast<Plot2d_PlotCurve*>( myCurves.findKey( curve ) );