Scalar bar ergonomics is updated.
Two Parameters ?Title width (%)? and ?Title height (%)? are replaced with one parameter ?Title size (%)?.
Two Parameters ?Labels width (%)? and ?Labels height (%)? are replaced with one parameter ?Labels size (%)?.
Format of labels is stored as integer value specified format precision instead of string value representing format. This integer value is used by Preferences and ?Bar properties? dialog box. All other internal objects (actors and presentations) uses format as string values. Two auxiliary methods VISU_Prs3dUtils::ToFormat() and VISU_Prs3dUtils::ToPrecision() are created for converting precision to format and vice versa.
SetUnitsVisible(anOrigin->IsUnitsVisible());
SetIsDistributionVisible(anOrigin->GetIsDistributionVisible());
- SetLabelsFormat(anOrigin->GetLabelsFormat());
-
+ SetLabelsFormat( anOrigin->GetLabelsFormat() );
+
SetBarOrientation(anOrigin->GetBarOrientation());
SetMinMaxController( anOrigin );
SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY());
SetSize(anOrigin->GetWidth(), anOrigin->GetHeight());
- SetRatios(anOrigin->GetTitleWidth(), anOrigin->GetTitleHeight(),
- anOrigin->GetLabelWidth(), anOrigin->GetLabelHeight(),
+ SetRatios(anOrigin->GetTitleSize(), anOrigin->GetLabelSize(),
anOrigin->GetBarWidth(), anOrigin->GetBarHeight());
SetLabels(anOrigin->GetLabels());
//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight,
- CORBA::Long theLabelWidth, CORBA::Long theLabelHeight,
+::SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize,
CORBA::Long theBarWidth, CORBA::Long theBarHeight)
{
- bool anIsSameValue = VISU::CheckIsSameValue(myTitleWidth, theTitleWidth);
- anIsSameValue &= VISU::CheckIsSameValue(myTitleHeight, theTitleHeight);
- anIsSameValue &= VISU::CheckIsSameValue(myLabelWidth, theLabelWidth);
- anIsSameValue &= VISU::CheckIsSameValue(myLabelHeight, theLabelHeight);
+ bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
+ anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
if(anIsSameValue)
VISU::TSetModified aModified(this);
- myTitleWidth = theTitleWidth;
- myTitleHeight = theTitleHeight;
- myLabelWidth = theLabelWidth;
- myLabelHeight = theLabelHeight;
+ myTitleSize = theTitleSize;
+ myLabelSize = theLabelSize;
myBarWidth = theBarWidth;
myBarHeight = theBarHeight;
myParamsTime.Modified();
//----------------------------------------------------------------------------
CORBA::Long
VISU::ColoredPrs3d_i
-::GetTitleWidth()
+::GetTitleSize()
{
- return myTitleWidth;
-}
-
-//----------------------------------------------------------------------------
-CORBA::Long
-VISU::ColoredPrs3d_i
-::GetTitleHeight()
-{
- return myTitleHeight;
+ return myTitleSize;
}
//----------------------------------------------------------------------------
CORBA::Long
VISU::ColoredPrs3d_i
-::GetLabelWidth()
+::GetLabelSize()
{
- return myLabelWidth;
-}
-
-//----------------------------------------------------------------------------
-CORBA::Long
-VISU::ColoredPrs3d_i
-::GetLabelHeight()
-{
- return myLabelHeight;
+ return myLabelSize;
}
//----------------------------------------------------------------------------
return myNumberOfLabels;
}
+//----------------------------------------------------------------------------
+
//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
SetIsDistributionVisible( aResourceMgr->booleanValue("VISU", "scalar_bar_show_distribution", false) ); // RKV
- QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" );
- SetLabelsFormat(aLabelsFormat.toLatin1().data());
+ int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 );
+ SetLabelsFormat( VISU::ToFormat( lp ).c_str() );
// Orientation
int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
myHeight = (myOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12;
myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
- myTitleWidth = 0;
- myTitleWidth = aResourceMgr->integerValue("VISU", propertyName + "title_width", myTitleWidth);
-
- myTitleHeight = 0;
- myTitleHeight = aResourceMgr->integerValue("VISU", propertyName + "title_height", myTitleHeight);
-
- myLabelWidth = 0;
- myLabelWidth = aResourceMgr->integerValue("VISU", propertyName + "label_width", myLabelWidth);
+ myTitleSize = 0;
+ myTitleSize = aResourceMgr->integerValue("VISU", propertyName + "title_size", myTitleSize);
- myLabelHeight = 0;
- myLabelHeight = aResourceMgr->integerValue("VISU", propertyName + "label_height", myLabelHeight);
+ myLabelSize = 0;
+ myLabelSize = aResourceMgr->integerValue("VISU", propertyName + "label_size", myLabelSize);
myBarWidth = 0;
myBarWidth = aResourceMgr->integerValue("VISU", propertyName + "bar_width", myBarWidth);
myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
- myTitleWidth = VISU::Storable::FindValue(theMap,"myTitleWidth").toInt();
- myTitleHeight = VISU::Storable::FindValue(theMap,"myTitleHeight").toInt();
- myLabelWidth = VISU::Storable::FindValue(theMap,"myLabelWidth").toInt();
- myLabelHeight = VISU::Storable::FindValue(theMap,"myLabelHeight").toInt();
+ myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt();
+ myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt();
myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
+
Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
+
Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
Storable::DataToStream( theStr, "myWidth", myWidth );
Storable::DataToStream( theStr, "myHeight", myHeight );
- Storable::DataToStream( theStr, "myTitleWidth", myTitleWidth );
- Storable::DataToStream( theStr, "myTitleHeight", myTitleHeight );
- Storable::DataToStream( theStr, "myLabelWidth", myLabelWidth );
- Storable::DataToStream( theStr, "myLabelHeight", myLabelHeight );
+ Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
+ Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
virtual
void
- SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight,
- CORBA::Long theLabelWidth, CORBA::Long theLabelHeight,
+ SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize,
CORBA::Long theBarWidth, CORBA::Long theBarHeight);
virtual
virtual
CORBA::Long
- GetTitleWidth();
-
- virtual
- CORBA::Long
- GetTitleHeight();
+ GetTitleSize();
virtual
CORBA::Long
- GetLabelWidth();
-
- virtual
- CORBA::Long
- GetLabelHeight();
+ GetLabelSize();
virtual
CORBA::Long
int myNumberOfLabels;
std::string myLabelsFormat;
+
VISU::ColoredPrs3dBase::Orientation myOrientation;
vtkFloatingPointType myPosition[2],
myWidth, myHeight,
- myTitleWidth, myTitleHeight,
- myLabelWidth, myLabelHeight,
+ myTitleSize, myLabelSize,
myBarWidth, myBarHeight;
//Font management
theScalarBar->SetTitle(GetScalarBarTitle().c_str());
theScalarBar->SetOrientation(GetBarOrientation());
theScalarBar->SetNumberOfLabels(GetLabels());
- theScalarBar->SetRatios(GetTitleWidth(), GetTitleHeight(),
- GetLabelWidth(), GetLabelHeight(),
+ theScalarBar->SetRatios(GetTitleSize(), GetLabelSize(),
GetBarWidth(), GetBarHeight());
theScalarBar->SetLabelFormat(GetLabelsFormat());
SetRange(aMin, aMax);
}
- QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" );
- SetLabelsFormat(aLabelsFormat.toLatin1().constData());
+ int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 );
+ SetLabelsFormat( VISU::ToFormat( lp ).c_str() );
// Orientation
int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
myHeight = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12;
myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
- myTitleWidth = aResourceMgr->doubleValue("VISU", propertyName + "title_width", 0);
- myTitleHeight = aResourceMgr->doubleValue("VISU", propertyName + "title_height", 0);
- myLabelWidth = aResourceMgr->doubleValue("VISU", propertyName + "label_width", 0);
- myLabelHeight = aResourceMgr->doubleValue("VISU", propertyName + "label_height", 0);
+ myTitleSize = aResourceMgr->doubleValue("VISU", propertyName + "title_size", 0);
+ myLabelSize = aResourceMgr->doubleValue("VISU", propertyName + "label_size", 0);
myBarWidth = aResourceMgr->doubleValue("VISU", propertyName + "bar_width", 0);
myBarHeight = aResourceMgr->doubleValue("VISU", propertyName + "bar_height", 0);
aScalarBar->SetWidth(GetWidth());
aScalarBar->SetHeight(GetHeight());
aScalarBar->SetNumberOfLabels(GetLabels());
- aScalarBar->SetRatios(myTitleWidth, myTitleHeight,
- myLabelWidth, myLabelHeight,
+ aScalarBar->SetRatios(myTitleSize, myLabelSize,
myBarWidth, myBarHeight);
aScalarBar->SetNumberOfLabels(GetLabels());
aScalarBar->SetLabelFormat(GetLabelsFormat());
myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
- myTitleWidth = VISU::Storable::FindValue(theMap,"myTitleWidth").toInt();
- myTitleHeight = VISU::Storable::FindValue(theMap,"myTitleHeight").toInt();
- myLabelWidth = VISU::Storable::FindValue(theMap,"myLabelWidth").toInt();
- myLabelHeight = VISU::Storable::FindValue(theMap,"myLabelHeight").toInt();
+ myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt();
+ myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt();
myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
Storable::DataToStream( theStr, "myWidth", myWidth );
Storable::DataToStream( theStr, "myHeight", myHeight );
- Storable::DataToStream( theStr, "myTitleWidth", myTitleWidth );
- Storable::DataToStream( theStr, "myTitleHeight", myTitleHeight );
- Storable::DataToStream( theStr, "myLabelWidth", myLabelWidth );
- Storable::DataToStream( theStr, "myLabelHeight", myLabelHeight );
+ Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
+ Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
}
//----------------------------------------------------------------------------
-CORBA::Long VISU::PointMap3d_i::GetTitleWidth()
+CORBA::Long VISU::PointMap3d_i::GetTitleSize()
{
- return myTitleWidth;
+ return myTitleSize;
}
//----------------------------------------------------------------------------
-CORBA::Long VISU::PointMap3d_i::GetTitleHeight()
-{
- return myTitleHeight;
-}
-
-//----------------------------------------------------------------------------
-CORBA::Long VISU::PointMap3d_i::GetLabelWidth()
+CORBA::Long VISU::PointMap3d_i::GetLabelSize()
{
- return myLabelWidth;
-}
-
-//----------------------------------------------------------------------------
-CORBA::Long VISU::PointMap3d_i::GetLabelHeight()
-{
- return myLabelHeight;
+ return myLabelSize;
}
//----------------------------------------------------------------------------
}
//----------------------------------------------------------------------------
-void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight,
- CORBA::Long theLabelWidth, CORBA::Long theLabelHeight,
+void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleSize,
+ CORBA::Long theLabelSize,
CORBA::Long theBarWidth, CORBA::Long theBarHeight)
{
- bool anIsSameValue = VISU::CheckIsSameValue(myTitleWidth, theTitleWidth);
- anIsSameValue &= VISU::CheckIsSameValue(myTitleHeight, theTitleHeight);
- anIsSameValue &= VISU::CheckIsSameValue(myLabelWidth, theLabelWidth);
- anIsSameValue &= VISU::CheckIsSameValue(myLabelHeight, theLabelHeight);
+ bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
+ anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
if(anIsSameValue)
return;
- myTitleWidth = theTitleWidth;
- myTitleHeight = theTitleHeight;
- myLabelWidth = theLabelWidth;
- myLabelHeight = theLabelHeight;
+ myTitleSize = theTitleSize;
+ myLabelSize = theLabelSize;
myBarWidth = theBarWidth;
myBarHeight = theBarHeight;
myParamsTime.Modified();
virtual void SetSize(CORBA::Double theWidth, CORBA::Double theHeight);
- virtual void SetRatios(CORBA::Long theTitleWidth, CORBA::Long theTitleHeight,
- CORBA::Long theLabelWidth, CORBA::Long theLabelHeight,
+ virtual void SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize,
CORBA::Long theBarWidth, CORBA::Long theBarHeight);
virtual CORBA::Double GetWidth();
virtual void SetLabelsFormat(const char* theFormat);
virtual char* GetLabelsFormat();
-
+
virtual void SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation);
virtual VISU::ColoredPrs3dBase::Orientation GetBarOrientation();
vtkFloatingPointType theB);
//-------------------------------------------------------------------
- virtual CORBA::Long GetTitleWidth();
- virtual CORBA::Long GetTitleHeight();
- virtual CORBA::Long GetLabelWidth();
- virtual CORBA::Long GetLabelHeight();
+ virtual CORBA::Long GetTitleSize();
+ virtual CORBA::Long GetLabelSize();
virtual CORBA::Long GetBarWidth();
virtual CORBA::Long GetBarHeight();
std::string myLabelsFormat;
vtkFloatingPointType myPosition[2],
myWidth, myHeight,
- myTitleWidth, myTitleHeight,
- myLabelWidth, myLabelHeight,
+ myTitleSize,
+ myLabelSize,
myBarWidth, myBarHeight;
bool myIsFixedRange;
CORBA::Float myOffset[3];
ProcessVoidEvent(new TEvent(this));
}
+ //----------------------------------------------------------------------------
+
+ std::string ToFormat( const int thePrec )
+ {
+ // "%-#6.3g"
+ char str[ 255 ];
+ sprintf( str, "%%-#.%dg", thePrec );
+ return str;
+ }
//----------------------------------------------------------------------------
+
+ int ToPrecision( const char* theFormat )
+ {
+ int N = strlen( theFormat );
+ int k = -1;
+ char str[ 255 ];
+ bool isOk = false;
+ for ( int i = 0; i < N; i++ )
+ {
+ if ( theFormat[ i ] == '.' )
+ k = 0;
+ else if ( theFormat[ i ] == 'g' )
+ {
+ str[ k ] = 0;
+ isOk = true;
+ break;
+ }
+ else if ( k >= 0 )
+ str[ k++ ] = theFormat[ i ];
+ }
+
+ int res = 0;
+ if ( isOk )
+ res = atoi( str );
+
+ return res;
+ }
};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#include <vtkTimeStamp.h>
-
namespace VISU
{
//----------------------------------------------------------------------------
~TSetModified();
};
+ Standard_EXPORT std::string ToFormat( const int thePrec );
+ Standard_EXPORT int ToPrecision( const char* theFormat );
+
//----------------------------------------------------------------------------
}
aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY());
aScalarBar->SetWidth(GetWidth());
aScalarBar->SetHeight(GetHeight());
- aScalarBar->SetRatios(GetTitleWidth(), GetTitleHeight(),
- GetLabelWidth(), GetLabelHeight(),
+ aScalarBar->SetRatios(GetTitleSize(), GetLabelSize(),
GetBarWidth(), GetBarHeight());
aScalarBar->SetNumberOfLabels(GetLabels());
aScalarBar->SetLabelFormat(GetLabelsFormat());