From: ouv Date: Fri, 25 Sep 2009 12:13:27 +0000 (+0000) Subject: Issue 0020336: [CEA 339] specifying a cut line with 2 points X-Git-Tag: V5_1_main_20090928 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=019efcb57eb56d52b9a4d9f735e3c2d4076a69ae;p=modules%2Fvisu.git Issue 0020336: [CEA 339] specifying a cut line with 2 points --- diff --git a/src/VISU_I/VISU_CutLinesBase_i.cc b/src/VISU_I/VISU_CutLinesBase_i.cc index 946db55d..7a43b3fe 100644 --- a/src/VISU_I/VISU_CutLinesBase_i.cc +++ b/src/VISU_I/VISU_CutLinesBase_i.cc @@ -274,7 +274,7 @@ VISU::CutLinesBase_i //--------------------------------------------------------------- void VISU::CutLinesBase_i -::BuildTableOfReal(SALOMEDS::SObject_var theSObject) +::BuildTableOfReal(SALOMEDS::SObject_var theSObject, bool theIsCutSegment) { try{ if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal"); @@ -422,12 +422,25 @@ VISU::CutLinesBase_i int iEnd = aXCont.size(); aTableOfReal->SetNbColumns(iEnd); TXCont::const_iterator aXContIter = aXCont.begin(); + vtkFloatingPointType aMinDist = *aXContIter; + aXContIter = aXCont.end(); + aXContIter--; + vtkFloatingPointType aMaxDist = *aXContIter; + if(aMaxDist <= aMinDist) + throw std::runtime_error("CutPlanes_i::BuildTableOfReal aMaxDist <= aMinDist !!!"); + aXContIter = aXCont.begin(); for(long i = 0; aXContIter != aXCont.end(); aXContIter++, i++){ vtkFloatingPointType aDist = *aXContIter; - aTableOfReal->PutValue(aDist,1,i+1); + vtkFloatingPointType aXVal = aDist; + if(theIsCutSegment){ + aXVal -= aMinDist; + if(!IsUseAbsoluteLength()) + aXVal /= (aMaxDist - aMinDist); + } + aTableOfReal->PutValue(aXVal,1,i+1); aString.sprintf("%d",i); aTableOfReal->SetColumnTitle(i+1,(const char*)aString.toLatin1()); - if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<_is_nil()) - pCutLines = dynamic_cast(GetServant(aCutLines).in()); + pCutLines = dynamic_cast(GetServant(aCutLines).in()); } SALOMEDS::Study_var aStudy = GetStudyDocument(); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; // look for component if ( !theRestoring ) { - SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() ); - // create SObject and set attributes - QString aComment; - if(pCutLines) - aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment()); - else{ - aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment()); - SALOMEDS::SObject_var aFatherSObject = SO->GetFather(); - if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){ - SALOMEDS::AttributeString_var aCommentAttr = - SALOMEDS::AttributeString::_narrow(anAttr); - CORBA::String_var aValue = aCommentAttr->Value(); - Storable::TRestoringMap aMap; - Storable::StringToMap(aValue.in(),aMap); - bool anIsExist; - QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); - if(anIsExist){ - if(aMethodName == "ImportTables"){ - aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment()); - } - } - } - } - - string anEntry = CreateAttributes( GetStudyDocument(), - SO->GetID(),//SComponent->GetID(), - "ICON_TREE_TABLE", - GetID(), - GetName(), - "", - aComment.toLatin1().constData(), - pCutLines ); - // create SObject referenced to real table object - mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() )); - if(pCutLines) { - pCutLines->BuildTableOfReal(mySObj); - } - // mpv (PAL5357): reference attributes are unnecessary now - //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj ); - //Builder->Addreference( refSO, SO ); + SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() ); + // create SObject and set attributes + QString aComment; + if(pCutLines) + aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment()); + else{ + aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment()); + SALOMEDS::SObject_var aFatherSObject = SO->GetFather(); + if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){ + SALOMEDS::AttributeString_var aCommentAttr = + SALOMEDS::AttributeString::_narrow(anAttr); + CORBA::String_var aValue = aCommentAttr->Value(); + Storable::TRestoringMap aMap; + Storable::StringToMap(aValue.in(),aMap); + bool anIsExist; + QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); + if(anIsExist){ + if(aMethodName == "ImportTables"){ + aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment()); + } + } + } + } + + string anEntry = CreateAttributes( GetStudyDocument(), + SO->GetID(),//SComponent->GetID(), + "ICON_TREE_TABLE", + GetID(), + GetName(), + "", + aComment.toLatin1().constData(), + pCutLines ); + // create SObject referenced to real table object + mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() )); + if(pCutLines) { + bool isCutSegment = dynamic_cast(pCutLines); + pCutLines->BuildTableOfReal(mySObj, isCutSegment); + } + // mpv (PAL5357): reference attributes are unnecessary now + //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj ); + //Builder->Addreference( refSO, SO ); } return this; diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index cf044b28..80a3a484 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -27,6 +27,7 @@ #include "VISU_Table_i.hh" #include "VISU_CutLinesBase_i.hh" +#include "VISU_CutSegment_i.hh" #include "VISU_Result_i.hh" #include "VISU_ViewManager_i.hh" @@ -214,52 +215,53 @@ VISU::Storable* VISU::Table_i::Build( int theRestoring ) if(!CORBA::is_nil(anObj)){ VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj); if(!aCutLines->_is_nil()) - pCutLines = dynamic_cast(GetServant(aCutLines).in()); + pCutLines = dynamic_cast(GetServant(aCutLines).in()); } SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; // look for component if ( !theRestoring ) { - SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() ); - // create SObject and set attributes - QString aComment; - if(pCutLines) - aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment()); - else{ - aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment()); - SALOMEDS::SObject_var aFatherSObject = SO->GetFather(); - if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){ - SALOMEDS::AttributeString_var aCommentAttr = - SALOMEDS::AttributeString::_narrow(anAttr); - CORBA::String_var aValue = aCommentAttr->Value(); - Storable::TRestoringMap aMap; - Storable::StringToMap(aValue.in(),aMap); - bool anIsExist; - QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); - if(anIsExist){ - if( aMethodName == "ImportTables" ){ - aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment()); - } - } - } - } + SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() ); + // create SObject and set attributes + QString aComment; + if(pCutLines) + aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment()); + else{ + aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment()); + SALOMEDS::SObject_var aFatherSObject = SO->GetFather(); + if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){ + SALOMEDS::AttributeString_var aCommentAttr = + SALOMEDS::AttributeString::_narrow(anAttr); + CORBA::String_var aValue = aCommentAttr->Value(); + Storable::TRestoringMap aMap; + Storable::StringToMap(aValue.in(),aMap); + bool anIsExist; + QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); + if(anIsExist){ + if( aMethodName == "ImportTables" ){ + aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment()); + } + } + } + } - string anEntry = CreateAttributes( GetStudyDocument(), - SO->GetID(),//SComponent->GetID(), - "ICON_TREE_TABLE", - GetID(), - GetName(), - "", - aComment.toLatin1().data(), - pCutLines ); - // create SObject referenced to real table object - mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() )); - if(pCutLines) { - pCutLines->BuildTableOfReal(mySObj); - } - // mpv (PAL5357): reference attributes are unnecessary now - //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj ); - //Builder->Addreference( refSO, SO ); + string anEntry = CreateAttributes( GetStudyDocument(), + SO->GetID(),//SComponent->GetID(), + "ICON_TREE_TABLE", + GetID(), + GetName(), + "", + aComment.toLatin1().data(), + pCutLines ); + // create SObject referenced to real table object + mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() )); + if(pCutLines) { + bool isCutSegment = dynamic_cast(pCutLines); + pCutLines->BuildTableOfReal(mySObj, isCutSegment); + } + // mpv (PAL5357): reference attributes are unnecessary now + //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj ); + //Builder->Addreference( refSO, SO ); } return this;