-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : VISU_Tools.cxx
#include "VISU_Table_i.hh"
#include "VISU_ViewManager_i.hh"
+#include <VISU_ActorBase.h>
+
+#include <LightApp_Displayer.h>
+
#include <SalomeApp_Study.h>
#include <SalomeApp_Application.h>
+#include <SalomeApp_Module.h>
#include <SPlot2d_ViewModel.h>
#include <Plot2d_ViewFrame.h>
#include <Plot2d_ViewManager.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
//=============================================================================
namespace VISU
plotCurve->setVerTitle( theCurve->GetName().c_str() );
plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
+ plotCurve->setScale( theCurve->GetScale() );
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() );
}
UpdateCurve( theCurve, thePlot, plotCurve, theDisplaying );
+ CurveVisibilityChanged(theCurve, theDisplaying, true, false, true);
if ( theDisplaying == VISU::eErase && plotCurve ) {
clist.removeAll(plotCurve );
}
}
thePlot->Repaint();
+ SetVisibilityState(table->GetEntry(),GetStateByDisplaying(theDisplaying));
}
+
}
//------------------------------------------------------------
}
thePlot->Repaint();
+
+ SetVisibilityState(theCurve->GetEntry(),GetStateByDisplaying(theDisplaying));
+ CurveVisibilityChanged(theCurve,theDisplaying,false, true, true);
}
//------------------------------------------------------------
VISU::Container_i* container,
int theDisplaying)
{
- if ( !thePlot )
+ if ( !thePlot || !container)
return;
if ( theDisplaying == VISU::eDisplayOnly )
thePlot->getCurves( clist );
if ( container->GetNbCurves() > 0 ) {
int nbCurves = container->GetNbCurves();
+ SetVisibilityState(container->GetEntry(), GetStateByDisplaying(theDisplaying));
for ( int k = 1; k <= nbCurves; k++ ) {
VISU::Curve_i* theCurve = container->GetCurve( k );
if ( theCurve && theCurve->IsValid() ) {
if ( plotCurve && theDisplaying == VISU::eErase ) {
clist.removeAll( plotCurve );
}
+ CurveVisibilityChanged(theCurve, theDisplaying, true, true, true);
}
}
}
+
thePlot->Repaint();
if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
thePlot->fitAll();
}
+
qApp->processEvents();
}
}
}
}
+
+ //------------------------------------------------------------
+ void SetVisibilityState(std::string entry, Qtx::VisibilityState state) {
+ if(entry.empty())
+ return;
+
+ if( SUIT_Session* aSession = SUIT_Session::session() )
+ if( SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSession->activeApplication()) )
+ if( SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy()) )
+ aStudy->setVisibilityState(entry.c_str(), state);
+
+ }
+
+ //------------------------------------------------------------
+ void SetVisibilityState(SALOME_Actor *theActor, Qtx::VisibilityState state) {
+ if(!theActor || !theActor->hasIO() || !theActor->getIO()->hasEntry())
+ return;
+ SetVisibilityState(theActor->getIO()->getEntry(), state);
+ }
+
+ void CurveVisibilityChanged(VISU::Curve_i* theCurve,
+ int theDisplaying,
+ bool updateCurve,
+ bool updateTable,
+ bool updateContainers) {
+
+ SUIT_Session* aSession = SUIT_Session::session();
+ if (!aSession) return;
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSession->activeApplication());
+ if ( !anApp ) return;
+
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+ if ( !aStudy ) return;
+
+ SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>( anApp->module( anApp->moduleTitle( "VISU" ) ) );
+ if ( !aModule ) return;
+
+ LightApp_Displayer* aDisplayer = aModule->displayer();
+
+ SUIT_ViewManager* aManager = anApp->activeViewManager();
+
+ Qtx::VisibilityState state = ( aManager && aManager->getType() == SPlot2d_Viewer::Type() ) ?
+ GetStateByDisplaying(theDisplaying) : Qtx::UnpresentableState;
+
+ if ( updateCurve )
+ SetVisibilityState( theCurve->GetEntry(), state );
+
+ if ( updateTable ) {
+ Table_i* aTable = theCurve->getTable();
+ if ( aTable && !(aStudy->visibilityState( aTable->GetEntry().c_str() ) == state) ) {
+ _PTR(SObject) TableSO = aStudy->studyDS()->FindObjectID( aTable->GetEntry() );
+ if ( TableSO ) {
+ bool isTableVisible = false;
+ if ( aDisplayer && state != Qtx::UnpresentableState ) {
+ _PTR(ChildIterator) Iter = aStudy->studyDS()->NewChildIterator( TableSO );
+ for ( ; Iter->More() && !isTableVisible ; Iter->Next() ) {
+ CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
+ if ( CORBA::is_nil( childObject ) ) continue;
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( childObject.in() ).in() );
+ isTableVisible = aCurve && aDisplayer->IsDisplayed( aCurve->GetEntry().c_str() );
+ }
+ } // if ( aDisplayer ... )
+ if ( state != Qtx::UnpresentableState )
+ SetVisibilityState( aTable->GetEntry(), ( isTableVisible ? Qtx::ShownState : Qtx::HiddenState ) );
+ else
+ SetVisibilityState( aTable->GetEntry(), state );
+ } // if ( TableSO )
+ } // if ( aTable )
+ } // if ( updateTable )
+
+ if ( updateContainers ) {
+ ContainerSet aContainers = theCurve->getContainers();
+ ContainerSet::ConstIterator it = aContainers.begin();
+ for ( ; it != aContainers.end(); it++ ) {
+ //Check that state of container is not set already
+ if(aStudy->visibilityState(*it) == state) continue;
+ _PTR(SObject) aSObject = aStudy->studyDS()->FindObjectID( (*it).toLatin1().data() );
+ if ( !aSObject ) continue;
+ bool isContainerDisplayed = false;
+ if ( aDisplayer && state != Qtx::UnpresentableState ) {
+ CORBA::Object_var anObj = VISU::ClientSObjectToObject( aSObject );
+ if ( CORBA::is_nil( anObj ) ) continue;
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj.in() ).in() );
+ if ( !aContainer ) continue;
+ int nbCurves = aContainer->GetNbCurves();
+ for ( int k = 1; k <= nbCurves && !isContainerDisplayed; k++ ) {
+ VISU::Curve_i* aCurve = aContainer->GetCurve( k );
+ isContainerDisplayed = aCurve && aDisplayer->IsDisplayed( aCurve->GetEntry().c_str() );
+ }
+ } // if ( aDisplayer ... )
+ if ( state != Qtx::UnpresentableState )
+ SetVisibilityState( (*it).toLatin1().constData(), ( isContainerDisplayed ? Qtx::ShownState : Qtx::HiddenState ) );
+ else {
+ SetVisibilityState( (*it).toLatin1().constData(), state );
+ }
+ } // for ( ; it != aContainers.end(); it++ )
+ } //updateContainers
+ }
+
+ Qtx::VisibilityState GetStateByDisplaying(int theDisplaying)
+ {
+ Qtx::VisibilityState state = Qtx::UnpresentableState;
+ if(theDisplaying == eDisplayAll ||
+ theDisplaying == eDisplay ||
+ theDisplaying == eDisplayOnly ) {
+ state = Qtx::ShownState;
+
+ } else if (theDisplaying == eErase || theDisplaying == eEraseAll) {
+ state = Qtx::HiddenState;
+ }
+ return state;
+ }
+
+ void updateContainerVisibility(VISU::Container_i* theContainer)
+ {
+ if ( !theContainer ) return;
+
+ SUIT_Session* aSession = SUIT_Session::session();
+ if (!aSession) return;
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSession->activeApplication());
+ if ( !anApp ) return;
+
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+ if ( !aStudy ) return;
+
+ SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>( anApp->module( anApp->moduleTitle( "VISU" ) ) );
+ if ( !aModule ) return;
+
+ SUIT_ViewManager* aManager = anApp->activeViewManager();
+ int nbCurves = theContainer->GetNbCurves();
+
+ Qtx::VisibilityState state = ( aManager && aManager->getType() == SPlot2d_Viewer::Type() && nbCurves > 0 ) ?
+ Qtx::HiddenState : Qtx::UnpresentableState;
+
+ LightApp_Displayer* aDisplayer = aModule->displayer();
+
+ if ( nbCurves > 0 && aDisplayer ) {
+ for ( int k = 1; k <= nbCurves; k++ ) {
+ VISU::Curve_i* aCurve = theContainer->GetCurve( k );
+ if ( aCurve && aDisplayer->IsDisplayed( aCurve->GetEntry().c_str() ) ) {
+ state = Qtx::ShownState;
+ break;
+ }
+ }
+ }
+ aStudy->setVisibilityState( theContainer->GetEntry().c_str(), state );
+ }
}