-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// 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
//
// GEOM GEOMGUI : GUI for Geometry component
#include <GEOM_OCCFilter.h>
#include <GEOM_Actor.h>
-#include <GEOM_AssemblyBuilder.h>
#include <GEOM_AISShape.hxx>
#include <GEOM_AISVector.hxx>
#include <GEOM_AISTrihedron.hxx>
#include <SUIT_ViewManager.h>
#include <SUIT_ResourceMgr.h>
+
#include <SalomeApp_Study.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+#include <LightApp_DataObject.h>
#include <SalomeApp_TypeFilter.h>
#include <SalomeApp_Tools.h>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS.hxx>
// VTK Includes
#include <vtkActorCollection.h>
}
}
-static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin )
+int GEOM_Displayer::getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin )
{
if ( shape.IsNull() )
return TopAbs_SHAPE;
return ret;
}
-static bool isCompoundOfVertices( const TopoDS_Shape& theShape )
+bool GEOM_Displayer::isCompoundOfVertices( const TopoDS_Shape& theShape )
{
return theShape.ShapeType() == TopAbs_COMPOUND && getMinMaxShapeType( theShape, false ) == TopAbs_VERTEX;
}
if ( prs )
{
- vf->BeforeDisplay( this );
+ vf->BeforeDisplay( this, prs );
vf->Display( prs );
- vf->AfterDisplay( this );
+ vf->AfterDisplay( this, prs );
if ( updateViewer )
vf->Repaint();
int aMgrId = getViewManagerId(vf);
SalomeApp_Study* aStudy = getStudy();
aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 1 );
-
+
+ setVisibilityState(theIO->getEntry(), Qtx::ShownState);
delete prs; // delete presentation because displayer is its owner
}
if ( vf ) {
SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
if ( prs ) {
+ vf->BeforeErase( this, prs );
vf->Erase( prs, forced );
+ vf->AfterErase( this, prs );
if ( updateViewer )
vf->Repaint();
delete prs; // delete presentation because displayer is its owner
int aMgrId = getViewManagerId(vf);
SalomeApp_Study* aStudy = getStudy();
aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 0 );
+
+ setVisibilityState(theIO->getEntry(), Qtx::HiddenState);
}
}
}
if(useStudy){
aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
- aDefPropMap = getDefaultPropepryMap(SOCC_Viewer::Type());
- bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
-
- if(isDiff)
- aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
+ aDefPropMap = getDefaultPropertyMap(SOCC_Viewer::Type());
+ MergePropertyMaps(aPropMap, aDefPropMap);
}
//Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" );
QStringList uv = anIsos.split(DIGIT_SEPARATOR);
anUIsoNumber = uv[0].toInt();
aVIsoNumber = uv[1].toInt();
- AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble());
+ //AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble());
} else {
anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
theActors->AddItem( aTrh );
}
else {
- theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, myType == GEOM_VECTOR );
+ PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type());
+
QString anEntry;
if(!myIO.IsNull()) {
aMgrId = getViewManagerId(myViewFrame);
anEntry = myIO->getEntry();
}
useStudy = !anEntry.isEmpty() && aMgrId != -1;
+
+
+ theActors = vtkActorCollection::New();
+ GEOM_Actor* aGeomActor = GEOM_Actor::New();
+ aGeomActor->SetShape(myShape,aDefPropMap.value(DEFLECTION_COEFF_PROP).toDouble(),myType == GEOM_VECTOR);
+ theActors->AddItem(aGeomActor);
+ aGeomActor->Delete();
- if(useStudy){
+ if(useStudy) {
aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
- PropMap aDefPropMap = getDefaultPropepryMap(SOCC_Viewer::Type());
- bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
- if(isDiff)
- aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
+ MergePropertyMaps(aPropMap, aDefPropMap);
}
}
aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
aGeomGActor->setDisplayMode(aPropMap.value(DISPLAY_MODE_PROP).toInt());
- aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble(), aGeomGActor->GetIsRelative());
+ aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
vtkFloatingPointType aColor[3] = {1.,0.,0.};
if(aPropMap.contains(COLOR_PROP)) {
* [ Reimplemented from SALOME_Displayer ]
*/
//=================================================================
-void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCViewType& )
+void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
{
SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
if ( vf )
}
}
-void GEOM_Displayer::AfterDisplay( SALOME_View*, const SALOME_OCCViewType& )
+void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
{
+ SalomeApp_Study* aStudy = getStudy();
+ if (!aStudy) return;
+ SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
+ if ( vf && !p->IsNull() ) {
+ int aMgrId = getViewManagerId( vf );
+ Handle(AIS_InteractiveContext) ic = vf->getAISContext();
+ const SOCC_Prs* prs = dynamic_cast<const SOCC_Prs*>( p );
+ if ( !ic.IsNull() && prs ) {
+ AIS_ListOfInteractive objects;
+ prs->GetObjects( objects );
+ AIS_ListIteratorOfListOfInteractive it( objects );
+ for ( ; it.More(); it.Next() ) {
+ Handle(GEOM_AISShape) sh = Handle(GEOM_AISShape)::DownCast( it.Value() );
+ if ( sh.IsNull() ) continue;
+ Handle(SALOME_InteractiveObject) IO = sh->getIO();
+ if ( IO.IsNull() ) continue;
+ PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, IO->getEntry() );
+ if ( aPropMap.contains( TRANSPARENCY_PROP ) ) {
+ double transparency = aPropMap.value(TRANSPARENCY_PROP).toDouble();
+ ic->SetTransparency( sh, transparency, true );
+ }
+ }
+ }
+ }
}
-
//=================================================================
/*!
* GEOM_Displayer::SetColor
myShape = theShape;
}
-bool GEOM_Displayer::canBeDisplayed( const QString& /*entry*/, const QString& viewer_type ) const
+bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
{
- return viewer_type==SOCC_Viewer::Type() || viewer_type==SVTK_Viewer::Type();
+ return viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type();
}
int GEOM_Displayer::SetDisplayMode( const int theMode )
-PropMap GEOM_Displayer::getDefaultPropepryMap(const QString& viewer_type){
+PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
PropMap aDefaultMap;
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
//1. Visibility
//7. Deflection Coeff
double aDC;
- //rnv: Currently deflection coefficient is not supported by VTK viewer.
+
if(viewer_type == SOCC_Viewer::Type()) {
- double aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
+ aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
} else if( viewer_type==SVTK_Viewer::Type()) {
- aDC = 0.0;
+ aDC = 0.001;
}
+
aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
return aDefaultMap;
}
return aSColor;
}
+
+
+void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
+ const bool eraseOnlyChildren) {
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if ( !app )
+ return;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( !appStudy )
+ return;
+
+ LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
+
+ if( !parent)
+ return;
+
+ // Erase from all views
+ QList<SALOME_View*> views;
+ SALOME_View* view;
+ ViewManagerList vmans = app->viewManagers();
+ SUIT_ViewManager* vman;
+ foreach ( vman, vmans ) {
+ SUIT_ViewModel* vmod = vman->getViewModel();
+ view = dynamic_cast<SALOME_View*> ( vmod );
+ if ( view )
+ views.append( view );
+ }
+
+ if( views.count() == 0 )
+ return;
+
+ //Erase childrens w/o update views
+ DataObjectList listObj = parent->children( true );
+ SUIT_DataObject* obj;
+ foreach( obj, listObj ) {
+ LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
+ if(l_obj)
+ foreach ( view, views ) {
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
+ Erase(anIO, false, false, view);
+ }
+ }
+
+ //Erase parent with view update or repaint views
+ foreach ( view, views ) {
+ if(!eraseOnlyChildren)
+ Erase(theIO, false, true, view);
+ else
+ view->Repaint();
+ }
+}