/*! Sets scaling coefficient of the curve to 1.0.
*/
void RemoveScale();
+
+ /*!
+ * Switches on/off displaying of the deviation labels
+ * on the curve.
+ * \param flag is used to switch on/off the deviation
+ * labels on the curve.
+ */
+ void ShowDeviation(in boolean flag);
};
//-------------------------------------------------------
<source>UNITS_LBL</source>
<translation>Units</translation>
</message>
+ <message>
+ <source>DVTN_LBL</source>
+ <translation>Deviation</translation>
+ </message>
<message>
<source>VISU_3DCACHE_PREFERENCES</source>
<translation>3D Cache</translation>
<source>MEN_VISU_LINEQUAD_MODE</source>
<translation>Lines</translation>
</message>
+ <message>
+ <source>MEN_VISU_SHOW_DEVIATION</source>
+ <translation>Show Deviation</translation>
+ </message>
<message>
<source>TOOL_IMPORT</source>
<translation>Import</translation>
_PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
_PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() );
if(IsSObjectTable(aSObject)){
- VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+ VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, aTable ,GetDesktop(this));
if(aDlg->exec() == QDialog::Accepted){
if(!IsStudyLocked(aStudy)){
// if study is not locked - create new container, create curves and insert them
for( int i = 0; i < verIndices.count(); i++ ){
bool isV2 = ver2Indices.contains(verIndices[i]);
VISU::Curve_var aCurveObject =
- GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1, isV2 );
+ GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(),
+ aDlg->idx(horIndex)+1,
+ aDlg->idx(verIndices[i])+1,
+ aDlg->idx(zIndices[i])+1, isV2 );
if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
bool isAuto;
int marker, line, lineWidth;
// check if Table SObject is selected
_PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
if(IsSObjectTable(aSObject)){
- VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+ VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, NULL, GetDesktop(this));
if(aDlg->exec() == QDialog::Accepted){
_PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
if(!IsStudyLocked(aStudy)){
tr("MEN_VISU_LINEQUAD_MODE"), "",0, aParent, true,
this, SLOT(OnLineQuadMode()));
+ createAction(VISU_SHOW_DEVIATION, tr("MEN_VISU_SHOW_DEVIATION"),QIcon(),
+ tr("MEN_VISU_SHOW_DEVIATION"), "",0, aParent, true,
+ this, SLOT(OnShowDeviation()));
+
}
void
mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
mgr->insert( action( VISU_CURVE_SCALE ), -1, -1, -1 ); // curve scale
+ //Show deviation command on curve
+ mgr->insert( action( VISU_SHOW_DEVIATION ), -1, -1, -1 ); // deviation
mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 );
mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 );
mgr->setRule( action( VISU_FILE_INFO ), "selcount=1 and type in {'VISU::TRESULT'}" );
mgr->setRule( action( VISU_EXPORT_MED ), "selcount=1 and type in {'VISU::TRESULT'}" );
+
+ aRule = "isPlot2dViewer and isVisible and selcount=1 and type='VISU::TCURVE' and hasDeviation";
+ mgr->setRule (action(VISU_SHOW_DEVIATION), aRule , QtxPopupMgr::VisibleRule);
+ aRule = "isPlot2dViewer and isVisible and selcount > 0 and type='VISU::TCURVE' and hasDeviation and isDeviationDisplayed";
+ mgr->setRule (action(VISU_SHOW_DEVIATION), aRule , QtxPopupMgr::ToggleRule);
}
void VisuGUI::createPanels()
return false;
}
+void VisuGUI::OnShowDeviation() {
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.size() != 1)
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
+
+ if(aBase->GetType() == VISU::TCURVE) {
+ if(!IsStudyLocked(GetCStudy(GetAppStudy(this)))){
+ // Curve object
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)) {
+ aCurve->ShowDeviation(!aCurve->isDeviationShown());
+ PlotCurve(this, aCurve, VISU::eDisplay);
+ }
+ }
+ }
+}
+
/*!
Rename object by entry.
\param entry entry of the object
void OnArcQuadMode();
void OnLineQuadMode();
+ void OnShowDeviation();
+
// MULTIPR
void OnMultiprViewFullRes();
void OnMultiprViewMediumRes();
#define VISU_ARCQUAD_MODE 4401
#define VISU_LINEQUAD_MODE 4402
+#define VISU_SHOW_DEVIATION 4501
+
#endif
else if ( p == "isValuesLabeled" ) val = QVariant( isValuesLabeled( ind ) );
else if ( p == "isScalarBarVisible" ) val = QVariant( isScalarBarVisible( ind ) );
else if ( p == "quadratic2DMode" ) val = QVariant( quadratic2DMode(ind) );
+ else if ( p == "hasDeviation" ) val = QVariant( hasDeviation(ind) );
+ else if ( p == "isDeviationDisplayed" ) val = QVariant( isDeviationDisplayed(ind) );
}
return val;
{
return TPopupDispatcher<TGetQuadratic2DRepresentation>()(myModule, entry(ind));
}
+
+
+bool VisuGUI_Selection::hasDeviation(const int ind) const {
+ SalomeApp_Study* aSStudy = GetStudy();
+ if ( !aSStudy )
+ return false;
+
+ _PTR(Study) aStudy = GetCStudy( aSStudy );
+ if ( aStudy ) {
+ _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() );
+ if ( SO ) {
+ CORBA::Object_var anObj = VISU::ClientSObjectToObject( SO );
+ if( !CORBA::is_nil( anObj )) {
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( anObj ).in()) ) {
+ return aCurve->hasDeviation();
+ }
+ }
+ }
+ }
+ return false;
+}
+
+bool VisuGUI_Selection::isDeviationDisplayed(const int ind) const {
+ SalomeApp_Study* aSStudy = GetStudy();
+ if ( !aSStudy )
+ return false;
+
+ _PTR(Study) aStudy = GetCStudy( aSStudy );
+ if ( aStudy ) {
+ _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() );
+ if ( SO ) {
+ CORBA::Object_var anObj = VISU::ClientSObjectToObject( SO );
+ if( !CORBA::is_nil( anObj )) {
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( anObj ).in()) ) {
+ return aCurve->isDeviationShown();
+ }
+ }
+ }
+ }
+ return false;
+}
\ No newline at end of file
QString resolutionState( const int ) const;
QString quadratic2DMode( const int ) const;
+ bool hasDeviation(const int) const;
+ bool isDeviationDisplayed(const int) const;
private:
bool findDisplayedCurves( const int, bool ) const;
/*!
Constructor
*/
-VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent )
- : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
+VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, VISU::Table_i* table , QWidget* parent )
+ : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
+ myTable(table)
{
setModal( true );
setWindowTitle( tr("TLT_SETUP_PLOT2D") );
QLabel* labAssigned = new QLabel( tr( "ASSIGNED" ), frame );
QLabel* labData = new QLabel( tr( "DATA_LBL" ), frame );
QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame );
+ QLabel* labDvtn = new QLabel( tr( "DVTN_LBL" ), frame );
QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame );
labAxis->setAlignment( Qt::AlignCenter );
labAssigned->setAlignment( Qt::AlignCenter );
labData->setAlignment( Qt::AlignCenter );
labUnit->setAlignment( Qt::AlignCenter );
+ labDvtn->setAlignment( Qt::AlignCenter );
labAttr->setAlignment( Qt::AlignCenter );
QFont font = labAxis->font(); font.setBold( true );
labAxis->setFont( font );
labAssigned->setFont( font );
labData->setFont( font );
labUnit->setFont( font );
+ labDvtn->setFont( font );
labAttr->setFont( font );
frameLayout->addWidget( labAxis, 0, 0, 1, 3 );
frameLayout->addWidget( labData, 0, 6 );
lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
frameLayout->addWidget( lin, 0, 7 );
+
frameLayout->addWidget( labUnit, 0, 8 );
lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
frameLayout->addWidget( lin, 0, 9 );
- frameLayout->addWidget( labAttr, 0, 10, 1, 5 );
+
+ frameLayout->addWidget( labDvtn, 0, 10 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addWidget( lin, 0, 11 );
+
+ frameLayout->addWidget( labAttr, 0, 12, 1, 5 );
//frameLayout->setColStretch( 15, 5 );
lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
- frameLayout->addWidget( lin, 1, 0, 1, 16 );
+ frameLayout->addWidget( lin, 1, 0, 1, 17 );
int row = 2;
_PTR(GenericAttribute) anAttr;
QStringList rows;
for ( int i = 0; i < nbRows; i++ )
rows.append( rowTitles[i].c_str() );
-
+
+ int nbItems=0;
for ( int i = 0; i < nbRows; i++ ) {
+ if(myTable && myTable->isDeviationRow(i)) continue;
VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
item->createWidgets( frame, rows );
frameLayout->addWidget( item->myHBtn, row, 0 );
frameLayout->addWidget( item->myUnitLab, row, 8 );
if ( rowUnits.size() > 0 )
item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
- frameLayout->addWidget( item->myAutoCheck, row, 10 );
- frameLayout->addWidget( item->myLineCombo, row, 11 );
- frameLayout->addWidget( item->myLineSpin, row, 12 );
- frameLayout->addWidget( item->myMarkerCombo, row, 13 );
- frameLayout->addWidget( item->myColorBtn, row, 14 );
+
+ frameLayout->addWidget( item->myDvtnLab, row, 10 );
+ if(myTable && myTable->hasDeviationData(i)) {
+ QString lbl = VISU::Table_i::deviationLabel(myTable->getDeviationInfo(i));
+ if(lbl.size() > 0 )
+ item->myDvtnLab->setText(lbl);
+ }
+
+ frameLayout->addWidget( item->myAutoCheck, row, 12 );
+ frameLayout->addWidget( item->myLineCombo, row, 13 );
+ frameLayout->addWidget( item->myLineSpin, row, 14 );
+ frameLayout->addWidget( item->myMarkerCombo, row, 15 );
+ frameLayout->addWidget( item->myColorBtn, row, 16 );
connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) );
myItems.append( item );
+ myIdxMap[nbItems] = i;
+ nbItems++;
row++;
}
}
QStringList rows;
for ( int i = 0; i < nbRows; i++ )
rows.append( rowTitles[i].c_str() );
-
+ int nbItems = 0;
for ( int i = 0; i < nbRows; i++ ) {
+ if(myTable && myTable->isDeviationRow(i)) continue;
VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
item->createWidgets( frame, rows );
frameLayout->addWidget( item->myHBtn, row, 0 );
frameLayout->addWidget( item->myUnitLab, row, 8 );
if ( rowUnits.size() > 0 )
item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
- frameLayout->addWidget( item->myAutoCheck, row, 10 );
- frameLayout->addWidget( item->myLineCombo, row, 11 );
- frameLayout->addWidget( item->myLineSpin, row, 12 );
- frameLayout->addWidget( item->myMarkerCombo, row, 13 );
- frameLayout->addWidget( item->myColorBtn, row, 14 );
+
+ frameLayout->addWidget( item->myDvtnLab, row, 10 );
+
+ frameLayout->addWidget( item->myDvtnLab, row, 10 );
+ if(myTable && myTable->hasDeviationData(i)) {
+ QString lbl = VISU::Table_i::deviationLabel(myTable->getDeviationInfo(i));
+ if(lbl.size() > 0 )
+ item->myDvtnLab->setText(lbl);
+ }
+
+ frameLayout->addWidget( item->myAutoCheck, row, 12 );
+ frameLayout->addWidget( item->myLineCombo, row, 13 );
+ frameLayout->addWidget( item->myLineSpin, row, 14 );
+ frameLayout->addWidget( item->myMarkerCombo, row, 15 );
+ frameLayout->addWidget( item->myColorBtn, row, 16 );
connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) );
myItems.append( item );
+ myIdxMap[nbItems] = i;
+ nbItems++;
row++;
}
}
frameLayout->addWidget( lin, 2, 5, row, 1 );
lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
frameLayout->addWidget( lin, 2, 7, row, 1 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addWidget( lin, 2, 9, row, 1 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addWidget( lin, 2, 11, row, 1 );
+
//frameLayout->setRowStretch( row+1, 5 );
myView->setWidget( frame );
SPlot2d_Curve* curve = new SPlot2d_Curve();
// curve titles
if ( rowTitles.size() > 0 ) {
- curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
- curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
+ curve->setHorTitle( QString( rowTitles[ idx(horIndex) ].c_str() ) );
+ curve->setVerTitle( QString( rowTitles[ idx(verIndex[i]) ].c_str() ) );
}
// curve units
if ( rowUnits.size() > 0 ) {
- curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
- curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
+ curve->setHorUnits( QString( rowUnits[ idx(horIndex) ].c_str() ) );
+ curve->setVerUnits( QString( rowUnits[ idx(verIndex[i]) ].c_str() ) );
}
// curve data
int nbPoints = 0;
for ( j = 1; j <= nbCols; j++ ) {
- if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) )
+ if ( tblIntAttr->HasValue( idx(horIndex) + 1, j ) && tblIntAttr->HasValue( idx(verIndex[i])+1, j ) )
nbPoints++;
}
if ( nbPoints > 0 ) {
double* yList = new double[ nbPoints ];
QStringList zList;
for ( j = 1; j <= nbCols; j++ ) {
- if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) {
- xList[j-1] = tblIntAttr->GetValue( horIndex +1, j );
- yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j );
- zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
+ if ( tblIntAttr->HasValue( idx(horIndex)+1, j ) && tblIntAttr->HasValue( idx(verIndex[i])+1, j ) ) {
+ xList[j-1] = tblIntAttr->GetValue( idx(horIndex) +1, j );
+ yList[j-1] = tblIntAttr->GetValue( idx(verIndex[i])+1, j );
+ zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( idx(zIndices[i])+1, j ) ) );
}
}
curve->setData( xList, yList, nbPoints, zList );
SPlot2d_Curve* curve = new SPlot2d_Curve();
// curve titles
if ( rowTitles.size() > 0 ) {
- curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
- curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
+ curve->setHorTitle( QString( rowTitles[ idx(horIndex) ].c_str() ) );
+ curve->setVerTitle( QString( rowTitles[ idx(verIndex[i]) ].c_str() ) );
}
// curve units
if ( rowUnits.size() > 0 ) {
- curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
- curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
+ curve->setHorUnits( QString( rowUnits[ idx(horIndex) ].c_str() ) );
+ curve->setVerUnits( QString( rowUnits[ idx(verIndex[i]) ].c_str() ) );
}
// curve data
int nbPoints = 0;
for ( j = 1; j <= nbCols; j++ ) {
- if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) )
+ if ( tblRealAttr->HasValue( idx(horIndex)+1, j ) && tblRealAttr->HasValue( idx(verIndex[i])+1, j ) )
nbPoints++;
}
if ( nbPoints > 0 ) {
double* yList = new double[ nbPoints ];
QStringList zList;
for ( j = 1; j <= nbCols; j++ ) {
- if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) {
- xList[j-1] = tblRealAttr->GetValue( horIndex +1, j );
- yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j );
- zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
+ if ( tblRealAttr->HasValue( idx(horIndex)+1, j ) && tblRealAttr->HasValue( idx(verIndex[i])+1, j ) ) {
+ xList[j-1] = tblRealAttr->GetValue( idx(horIndex) +1, j );
+ yList[j-1] = tblRealAttr->GetValue( idx(verIndex[i])+1, j );
+ zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( idx(zIndices[i])+1, j ) ) );
}
}
curve->setData( xList, yList, nbPoints, zList );
myTitleLab = new QLabel( parentWidget );
myUnitLab = new QLabel( parentWidget );
myUnitLab->setAlignment( Qt::AlignCenter);
+
+ myDvtnLab = new QLabel( parentWidget );
+ myDvtnLab->setAlignment( Qt::AlignCenter);
myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
myAutoCheck->setChecked( true );
#include <SALOMEDSClient_SObject.hxx>
+#include <VISU_Table_i.hh>
+
#include <QDialog>
#include <QList>
Q_OBJECT
public:
- VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent = 0 );
+ VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, VISU::Table_i* table ,QWidget* parent = 0 );
~VisuGUI_SetupPlot2dDlg();
void getCurves( QList<Plot2d_Curve*>& container );
void getCurvesSource( int& horIndex, QList<int>& verIndexes, QList<int>& ver2Indexes, QList<int>& zIndexes );
bool getCurveAttributes( const int vIndex, bool& isAuto, int& marker, int& line, int& lineWidth, QColor& color);
+ int idx(const int i) const {return myIdxMap[i];}
private:
void keyPressEvent( QKeyEvent* e );
QPushButton* myCancelBtn;
QPushButton* myHelpBtn;
QList<VisuGUI_ItemContainer*> myItems;
+ QMap<int,int> myIdxMap;
_PTR(SObject) myObject;
+ VISU::Table_i* myTable;
};
class VisuGUI_ItemContainer : public QObject
QToolButton* myV2Btn;
QLabel* myTitleLab;
QLabel* myUnitLab;
+ QLabel* myDvtnLab;
QCheckBox* myAutoCheck;
QComboBox* myLineCombo;
SalomeApp_IntSpinBox* myLineSpin;
#else
static int MYDEBUG = 0;
#endif
+
+//# Define delimeter
+#define TLT_DLM ":"
+
+//Absolute deviation
+#define D_MIN "min"
+#define D_MAX "max"
+
+//Percentage deviation
+#define D_PMIN "min%"
+#define D_PMAX "max%"
+
+#define D_EMIN "errmin"
+#define D_EMAX "errmax"
+
+#define D_EPMIN "errmin%"
+#define D_EPMAX "errmax%"
+
+#define D_ERR "error"
+#define D_ERRP "error%"
+
+
//----------------------------------------------------------------
// Table Object
//----------------------------------------------------------------
MESSAGE("Table_i::Table_i - "<<this);
mySObj = theStudy->FindObjectID(theObjectEntry);
myOrientation = VISU::Table::HORIZONTAL;
+ SetStudyDocument(theStudy);
+ BuildDeviationMap();
}
/*!
Destructor
}
}
}
+//----------------------------------------------------------------------------
+bool
+VISU::Table_i::parseTitle(const QString theTitle,
+ QString& theOutTitle,
+ DeviationType& theType,
+ bool& isMin) {
+ QStringList lst = theTitle.split(TLT_DLM);
+ theType = NoneDvtn;
+ isMin = false;
+ theOutTitle.clear();
+ if(lst.size() >= 2) {
+ QString s1 = lst[0];
+ QString s2 = lst[1];
+ if(QString::compare(lst[0], D_MIN, Qt::CaseInsensitive) == 0){
+ theType = AbsoluteDvtn;
+ isMin = true;
+ } else if(QString::compare(lst[0], D_MAX, Qt::CaseInsensitive) == 0) {
+ theType = AbsoluteDvtn;
+ isMin = false;
+ } else if(QString::compare(lst[0], D_PMIN, Qt::CaseInsensitive) == 0) {
+ theType = PercentageDvtn;
+ isMin = true;
+ } else if(QString::compare(lst[0], D_PMAX, Qt::CaseInsensitive) == 0) {
+ theType = PercentageDvtn;
+ isMin = false;
+ } else if(QString::compare(lst[0], D_EMIN, Qt::CaseInsensitive) == 0) {
+ theType = ErrorDvtn;
+ isMin = true;
+ } else if(QString::compare(lst[0], D_EMAX, Qt::CaseInsensitive) == 0) {
+ theType = ErrorDvtn;
+ isMin = false;
+ } else if(QString::compare(lst[0], D_EPMIN, Qt::CaseInsensitive) == 0) {
+ theType = ErrorPercentageDvtn;
+ isMin = true;
+ } else if(QString::compare(lst[0], D_EPMAX, Qt::CaseInsensitive) == 0) {
+ theType = ErrorPercentageDvtn;
+ isMin = false;
+ } else if(QString::compare(lst[0], D_ERR, Qt::CaseInsensitive) == 0) {
+ theType = SimpleErrorDvtn;
+ } else if(QString::compare(lst[0], D_ERRP, Qt::CaseInsensitive) == 0) {
+ theType = SimpleErrorPercentageDvtn;
+ }
+ }
+ if(theType == NoneDvtn){
+ return false;
+ } else {
+ for(int i = 1; i < lst.size();i++ )
+ theOutTitle += lst[i];
+ return true;
+ }
+}
+//----------------------------------------------------------------------------
+double
+VISU::Table_i
+::calculateDeviation(DeviationType theType, double value,double deviationValue, bool isMin){
+ double result;
+ switch(theType) {
+ case AbsoluteDvtn:
+ result = deviationValue;
+ break;
+ case PercentageDvtn:
+ result = value*deviationValue;
+ break;
+ case SimpleErrorDvtn:
+ case ErrorDvtn:
+ result = value + (isMin ? -1.0 : 1.0)*deviationValue;
+ break;
+ case ErrorPercentageDvtn:
+ case SimpleErrorPercentageDvtn:
+ result = value *( 1 + (isMin ? -1.0 : 1.0)*deviationValue);
+ break;
+ default: result = 0.;
+ }
+ return result;
+}
+
+QString
+VISU::Table_i
+::deviationLabel(DeviationData* info) {
+ QString lbl;
+ if(info) {
+ bool add = true;
+ switch(info->minDeviation()){
+ case SimpleErrorDvtn:
+ lbl = D_ERR;
+ add = false;
+ break;
+ case SimpleErrorPercentageDvtn:
+ lbl = D_ERRP;
+ add = false;
+ break;
+ case AbsoluteDvtn:
+ lbl = D_MIN;
+ break;
+ case PercentageDvtn:
+ lbl = D_PMIN;
+ break;
+ case ErrorDvtn:
+ lbl = D_EMIN;
+ break;
+ case ErrorPercentageDvtn:
+ lbl = D_EPMIN;
+ break;
+ }
+ if(add) {
+ lbl += " / ";
+ switch(info->maxDeviation()){
+ case AbsoluteDvtn:
+ lbl += D_MAX;
+ break;
+ case PercentageDvtn:
+ lbl += D_PMAX;
+ break;
+ case ErrorDvtn:
+ lbl += D_EMAX;
+ break;
+ case ErrorPercentageDvtn:
+ lbl += D_EPMAX;
+ break;
+ }
+ }
+ }
+ return lbl;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::Table_i
+::hasDeviationData(const int row) {
+ return myDeviationMap.contains(row);
+}
+
+//----------------------------------------------------------------------------
+VISU::DeviationData*
+VISU::Table_i::getDeviationInfo(const int row) {
+ if(hasDeviationData(row))
+ return &myDeviationMap[row];
+ return NULL;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::Table_i
+::isDeviationRow(const int row) {
+ DeviationMap::const_iterator it = myDeviationMap.begin();
+ for( ; it != myDeviationMap.end(); it++) {
+ if((*it).minRow() == row || (*it).maxRow() == row)
+ return true;
+ }
+ return false;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::BuildDeviationMap() {
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeTableOfInteger_var anInt;
+ SALOMEDS::AttributeTableOfReal_var aReal;
+ SALOMEDS::StringSeq_var rowTitles;
+ SALOMEDS::StringSeq_var rowUnits;
+
+ if ( !mySObj->_is_nil() ) {
+ if ( Builder->FindAttribute( mySObj, anAttr, "AttributeTableOfInteger" ) ) {
+ anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
+ rowTitles = anInt->GetRowTitles();
+ rowUnits = anInt->GetRowUnits();
+ }
+ else if ( Builder->FindAttribute( mySObj, anAttr, "AttributeTableOfReal" ) ) {
+ aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
+ rowTitles = aReal->GetRowTitles();
+ rowUnits = aReal->GetRowUnits();
+ }
+ }
+ int nbTitles = rowTitles->length();
+ int nbUnits = rowUnits->length();
+
+ QString realTitle;
+ DeviationType deviationType;
+ bool isMin;
+
+ //Deviation candidates map:
+ //Key - title without keyword, pair { "deviation type" , "id of row" }
+ QMap<QString, QPair<DeviationType,int> > minCandidatesMap;
+ QMap<QString, QPair<DeviationType,int> > maxCandidatesMap;
+ QMap<QString, QPair<DeviationType,int> > CandidatesMap;
+ if( nbTitles > 0 ) {
+ for(int i = 0; i < nbTitles; i++ ) {
+ if(parseTitle(rowTitles[i].in(), realTitle, deviationType, isMin)) {
+ if( deviationType == SimpleErrorDvtn || deviationType == SimpleErrorPercentageDvtn ){
+ if(!CandidatesMap.contains(realTitle)) {
+ CandidatesMap[realTitle] = QPair<DeviationType, int>(deviationType,i);
+ } else {
+ minCandidatesMap.remove(realTitle);
+ maxCandidatesMap.remove(realTitle);
+ CandidatesMap.remove(realTitle);
+ }
+ continue;
+ }
+ if(isMin) {
+ if(!minCandidatesMap.contains(realTitle)){
+ minCandidatesMap[realTitle] = QPair<DeviationType, int>(deviationType,i);
+ } else {
+ minCandidatesMap.remove(realTitle);
+ maxCandidatesMap.remove(realTitle);
+ CandidatesMap.remove(realTitle);
+ }
+ } else {
+ if(!maxCandidatesMap.contains(realTitle)){
+ maxCandidatesMap[realTitle] = QPair<DeviationType, int>(deviationType,i);
+ } else {
+ minCandidatesMap.remove(realTitle);
+ maxCandidatesMap.remove(realTitle);
+ CandidatesMap.remove(realTitle);
+ }
+ }
+ }
+ }
+ QString currentTitle;
+ for(int i = 0; i < nbTitles; i++ ) {
+ currentTitle = rowTitles[i].in();
+ if(minCandidatesMap.contains(currentTitle) && maxCandidatesMap.contains(currentTitle)) {
+ //check for the units
+ if(nbUnits > 0) {
+ if(i < nbUnits) {
+ const char* s1 = rowUnits[i].in();
+ const char* s2 = rowUnits[minCandidatesMap[currentTitle].second].in();
+ const char* s3 = rowUnits[maxCandidatesMap[currentTitle].second].in();
+ if(strcmp(s1,s2) != 0 || strcmp(s1,s3) != 0 ) continue;
+ } else continue;
+ }
+ myDeviationMap[i] = DeviationData(minCandidatesMap[currentTitle].second,
+ maxCandidatesMap[currentTitle].second,
+ minCandidatesMap[currentTitle].first,
+ maxCandidatesMap[currentTitle].first);
+ } else if(CandidatesMap.contains(currentTitle)) {
+ //check for the units
+ if(nbUnits > 0) {
+ if(i < nbUnits) {
+ const char* s1 = rowUnits[i].in();
+ const char* s2 = rowUnits[CandidatesMap[currentTitle].second].in();
+ if(strcmp(s1,s2) != 0) continue;
+ } else continue;
+ }
+ myDeviationMap[i] = DeviationData(CandidatesMap[currentTitle].second,
+ CandidatesMap[currentTitle].second,
+ CandidatesMap[currentTitle].first,
+ CandidatesMap[currentTitle].first);
+ }
+ }
+ }
+}
//----------------------------------------------------------------------------
SALOMEDS::SObject_var
CORBA::Long theHRow, CORBA::Long theVRow,
CORBA::Long theZRow, CORBA::Boolean theIsV2 )
: PrsObject_i(theStudy), myTable( theTable ), myHRow( theHRow ),
- myVRow( theVRow ), myZRow( theZRow ), myIsV2( theIsV2 )
+ myVRow( theVRow ), myZRow( theZRow ), myIsV2( theIsV2 ), myDeviationEnabled(false)
{
myAuto = true;
myLine = VISU::Curve::SOLIDLINE;
}
return 0;
}
+
+int VISU::Curve_i::GetDeviationData( double*& theMin, double*& theMax, QList<int>& theIndexes) {
+ if(!hasDeviation())
+ return 0;
+
+ theIndexes.clear();
+
+ DeviationData *info = myTable->getDeviationInfo(myVRow - 1);
+ int minRow = info->minRow() + 1;
+ int maxRow = info->maxRow() + 1;
+
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str());
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeTableOfInteger_var anInt;
+ SALOMEDS::AttributeTableOfReal_var aReal;
+
+ int nbPoints = 0;
+ if ( !SO->_is_nil() ) {
+ if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
+ anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
+ int nbCols = anInt->GetNbColumns();
+ int nbRows = anInt->GetNbRows();
+ if ( nbCols > 0 && myHRow > 0 && myVRow && minRow > 0 && maxRow > 0 &&
+ myHRow <= nbRows && myVRow <= nbRows && minRow <= nbRows && maxRow <= nbRows ) {
+ for ( int j = 1; j <= nbCols; j++ ) {
+ if ( anInt->HasValue( myHRow, j ) && anInt->HasValue( myVRow, j ) &&
+ anInt->HasValue( minRow, j ) && anInt->HasValue( maxRow, j ) )
+ nbPoints++;
+ }
+
+ if ( nbPoints > 0 ) {
+ theMin = new double[ nbPoints ];
+ theMax = new double[ nbPoints ];
+ int k = 0;
+ int value;
+ for ( int j = 1; j <= nbCols; j++ ) {
+ if ( anInt->HasValue( myHRow, j ) && anInt->HasValue( myVRow, j ) &&
+ anInt->HasValue( minRow, j ) && anInt->HasValue( maxRow, j )) {
+ value = anInt->GetValue(myVRow,j);
+ theMin[k] = Table_i::calculateDeviation(info->minDeviation(),value, anInt->GetValue(minRow,j), true);
+ theMax[k] = Table_i::calculateDeviation(info->maxDeviation(),value, anInt->GetValue(minRow,j), false);
+ k++;
+ theIndexes.push_back(j-1);
+ }
+ } // for ( ...
+ } // nbPoints > 0
+ } // nbCols > 0 && myHRow > 0 && myVRow ...
+ } // Builder->FindAttribute(...
+ else if( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
+ aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
+ int nbCols = aReal->GetNbColumns();
+ int nbRows = aReal->GetNbRows();
+ if ( nbCols > 0 && myHRow > 0 && myVRow && minRow > 0 && maxRow > 0 &&
+ myHRow <= nbRows && myVRow <= nbRows && minRow <= nbRows && maxRow <= nbRows) {
+ for ( int j = 1; j <= nbCols; j++ ) {
+ if ( aReal->HasValue( myHRow, j ) && aReal->HasValue( myVRow, j ) &&
+ aReal->HasValue( minRow, j ) && aReal->HasValue( maxRow, j ) )
+ nbPoints++;
+ }
+
+ if ( nbPoints > 0 ) {
+ theMin = new double[ nbPoints ];
+ theMax = new double[ nbPoints ];
+ int k = 0;
+ double value;
+ for ( int j = 1; j <= nbCols; j++ ) {
+ if ( aReal->HasValue( myHRow, j ) && aReal->HasValue( myVRow, j ) &&
+ aReal->HasValue( minRow, j ) && aReal->HasValue( maxRow, j )) {
+ value = aReal->GetValue(myVRow,j);
+ theMin[k] = Table_i::calculateDeviation(info->minDeviation(),value, aReal->GetValue(minRow,j), true);
+ theMax[k] = Table_i::calculateDeviation(info->maxDeviation(),value, aReal->GetValue(maxRow,j), false);
+ k++;
+ theIndexes.push_back(j-1);
+ }
+ } // for ( ..
+ } // nbPoints > 0
+ } // nbCols > 0 && myHRow > 0 && myVRow ...
+ } // Builder->FindAttribute( ...
+ } // !SO->_is_nil()
+ return nbPoints;
+}
/*!
Creates curve Plot2d presentation object
*/
return myContainers;
}
+/*!
+ Return true if on the curve were assigned deviation data
+*/
+bool VISU::Curve_i::hasDeviation() {
+ return myTable && myTable->hasDeviationData(myVRow-1);
+}
+
+/*!
+ Enable/disable deviation data displaying.
+*/
+void VISU::Curve_i::ShowDeviation(CORBA::Boolean flag) {
+ if(flag && hasDeviation())
+ myDeviationEnabled = flag;
+ else
+ myDeviationEnabled = false;
+}
+/*!
+ Return enable deviation flag
+*/
+bool VISU::Curve_i::isDeviationShown() {
+ return myDeviationEnabled;
+}
//----------------------------------------------------------------
// Container Object
#include <QStringList>
#include <QSet>
+#include <QMap>
class SPlot2d_Curve;
-namespace VISU{
+namespace VISU {
+ typedef enum {NoneDvtn = 0,
+ AbsoluteDvtn,
+ PercentageDvtn,
+ ErrorDvtn,
+ ErrorPercentageDvtn,
+ SimpleErrorDvtn,
+ SimpleErrorPercentageDvtn } DeviationType;
+
+ class VISU_I_EXPORT DeviationData {
+ public:
+ DeviationData(){
+ _minRow = -1;_maxRow = -1;
+ _minType = NoneDvtn;_maxType = NoneDvtn;
+ }
+ DeviationData(const int minC, const int maxC,
+ const DeviationType minT, const DeviationType maxT) {
+ _minRow = minC; _maxRow = maxC;
+ _minType = minT ; _maxType = maxT;
+ }
+ int minRow() const {return _minRow;}
+ int maxRow() const {return _maxRow;}
+ DeviationType minDeviation() const {return _minType;}
+ DeviationType maxDeviation() const {return _maxType;}
+
+ private:
+ int _minRow;
+ int _maxRow;
+ DeviationType _minType;
+ DeviationType _maxType;
+ };
+
+ typedef QMap<int, DeviationData> DeviationMap;
+
//==============================================================================
class VISU_I_EXPORT Table_i : public virtual POA_VISU::Table,
public virtual PrsObject_i
virtual void SortByRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
virtual void SortByColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+ virtual bool hasDeviationData(const int);
+ virtual bool isDeviationRow(const int);
+ virtual DeviationData* getDeviationInfo(const int);
virtual void RemoveFromStudy();
protected:
Storable* Build(int theRestoring);
void UpdateCurves(std::map<int, int> theMixData);
+ void BuildDeviationMap();
protected:
VISU::Table::Orientation myOrientation;
std::string myTitle;
SALOMEDS::SObject_var mySObj;
+ DeviationMap myDeviationMap;
public:
virtual Storable* Create();
const std::string& thePrefix,
CORBA::Boolean theIsMultiFile);
+ static bool parseTitle(const QString theTitle,
+ QString& theOutTitle,
+ DeviationType& theType,
+ bool& isMin);
+
+ static double calculateDeviation(DeviationType theType, double value,double deviationValue, bool isMin);
+
+ static QString deviationLabel(DeviationData* );
+
virtual void ToStream( std::ostringstream& theStr );
static const std::string myComment;
virtual const char* GetComment() const;
virtual SALOMEDS::SObject_var GetSObject();
+ virtual void ShowDeviation(CORBA::Boolean);
+ virtual bool isDeviationShown();
+ virtual bool hasDeviation();
+
protected:
Storable* Build(int theRestoring);
bool myAuto;
SALOMEDS::SObject_var mySObj;
ContainerSet myContainers;
+ bool myDeviationEnabled;
public:
virtual Storable* Create();
virtual std::string GetHorUnits();
virtual std::string GetVerUnits();
virtual int GetData( double*& theHorList, double*& theVerList, QStringList& );
+ virtual int GetDeviationData( double*& theMin, double*& theMax, QList<int>& );
virtual SPlot2d_Curve* CreatePresentation();
};
double* xList = 0;
double* yList = 0;
QStringList zList;
- int nbPoints = theCurve->GetData( xList, yList, zList );
+ int nbPoints = theCurve->GetData( xList, yList, zList );
if ( nbPoints > 0 && xList && yList ) {
plotCurve->setData( xList, yList, nbPoints, zList );
}
+ if(theCurve->isDeviationShown()){
+ double* min = 0;
+ double* max = 0;
+ QList<int> indexes;
+ int nbPoints = theCurve->GetDeviationData( min, max, indexes );
+ if ( nbPoints > 0 && min && max ) {
+ plotCurve->setDeviationData(min, max, indexes);
+ delete min;
+ delete max;
+ }
+ } else {
+ plotCurve->clearDeviationData();
+ }
if ( !theCurve->IsAuto() ) {
plotCurve->setLine( (Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
plotCurve->setMarker( (Plot2d::MarkerType)theCurve->GetMarker() );