- VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
- VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
- if (!vf) return NULL;
- if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
- vtkRenderer *aRen = vf->getRenderer();
- vtkActorCollection *anActColl = aRen->GetActors();
- vtkActor *anActor;
- VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
- for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
- if(anActor->IsA("VISU_Actor")){
- anVISUActor = VISU_Actor::SafeDownCast(anActor);
- if (thePrs == anVISUActor->GetPrs3d()) {
- aResActor = anVISUActor->GetParent();
- if(theDisplaing < eErase)
- aResActor->VisibilityOn();
- else
- aResActor->VisibilityOff();
- } else {
- if(theDisplaing > eDisplay)
- anVISUActor->VisibilityOff();
- else
- anVISUActor->VisibilityOn();
- }
- }
- }
- if (aResActor) {
- RepaintView(theStudyFrame);
- return aResActor;
- }
- if(thePrs != NULL && theDisplaing < eErase){
- try{
- anVISUActor = thePrs->CreateActor();
- vf->AddActor(anVISUActor);
- }catch(std::runtime_error& exc){
- INFOS(exc.what());
- return NULL;
- }
- }
- RepaintView(theStudyFrame);
- return anVISUActor;
- }
- void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
- if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
- if ( !theView )
- return;
- QList<Plot2d_Curve> clist;
- theView->getCurves( clist );
- if ( theDisplaying == eEraseAll ) {
- for ( int i = 0; i < clist.count(); i++ ) {
- if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
- theView->eraseCurve( clist.at( i ) );
- }
- }
- else if ( theDisplaying == eErase ) {
- for ( int i = 0; i < clist.count(); i++ ) {
- if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
- if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
- theView->eraseCurve( clist.at( i ) );
- }
- }
- }
- else if ( theDisplaying == eDisplay ) {
- bool bFound = false;
- for ( int i = 0; i < clist.count(); i++ ) {
- if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
- if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
- clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
- clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
- clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
- clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
- double* xList = 0;
- double* yList = 0;
- int nbPoints = theCurve->GetData( xList, yList );
- if ( nbPoints > 0 && xList && yList ) {
- clist.at( i )->setData( xList, yList, nbPoints );
- }
- if ( !theCurve->IsAuto() ) {
- clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
- clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
- SALOMEDS::Color color = theCurve->GetColor();
- clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- }
- clist.at( i )->setAutoAssign( theCurve->IsAuto() );
- theView->displayCurve( clist.at( i ) );
- bFound = true;
- }
- }
- if ( !bFound ) {
- Plot2d_Curve* crv = theCurve->CreatePresentation();
- if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
- if ( crv ) {
- theView->displayCurve( crv );
- theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
- theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
- SALOMEDS::Color newColor;
- newColor.R = crv->getColor().red()/255.;
- newColor.G = crv->getColor().green()/255.;
- newColor.B = crv->getColor().blue()/255.;
- theCurve->SetColor( newColor );
- crv->setAutoAssign( theCurve->IsAuto() );
- }
- }
- }
- else if ( theDisplaying == eDisplayOnly ) {
- bool bFound = false;
- for ( int i = 0; i < clist.count(); i++ ) {
- if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
- if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
- clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
- clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
- clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
- clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
- double* xList = 0;
- double* yList = 0;
- int nbPoints = theCurve->GetData( xList, yList );
- if ( nbPoints > 0 && xList && yList ) {
- clist.at( i )->setData( xList, yList, nbPoints );
- }
- if ( !theCurve->IsAuto() ) {
- clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
- clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
- SALOMEDS::Color color = theCurve->GetColor();
- clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- }
- clist.at( i )->setAutoAssign( theCurve->IsAuto() );
- theView->displayCurve( clist.at( i ) );
- bFound = true;
- }
- else {
- theView->eraseCurve( clist.at( i ) );
- }
- }
- if ( !bFound ) {
- Plot2d_Curve* crv = theCurve->CreatePresentation();
- if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
- if ( crv ) {
- theView->displayCurve( crv );
- theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
- theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
- SALOMEDS::Color newColor;
- newColor.R = crv->getColor().red()/255.;
- newColor.G = crv->getColor().green()/255.;
- newColor.B = crv->getColor().blue()/255.;
- theCurve->SetColor( newColor );
- crv->setAutoAssign( theCurve->IsAuto() );
- }
- }
- }