-// VISU OBJECT : interactive object for VISU entities implementation
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// 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
// 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
//
+
+// VISU OBJECT : interactive object for VISU entities implementation
// File : VISU_Prs3d_i.cc
// Author : Alexey PETROV
// Module : VISU
-
+//
#include "VISU_Prs3d_i.hh"
#include "VISU_Prs3dUtils.hh"
+#include "VISU_Gen_i.hh"
#include "VISU_PipeLine.hxx"
#include "VISU_Result_i.hh"
#include "VISU_Actor.h"
-#include "SALOME_Event.hxx"
+#include "SALOME_Event.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_MessageBox.h"
+
+#include <VTKViewer_MarkerUtils.h>
#include <vtkActorCollection.h>
#include <vtkUnstructuredGrid.h>
#include <boost/bind.hpp>
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
VISU::Prs3d_i::Prs3d_i() :
PrsObject_i(SALOMEDS::Study::_nil()),
myActorCollection(vtkActorCollection::New()),
- myIsActiveSatate(true)
+ myIsActiveSatate(true),
+ myIsForcedHidden(false)
{
if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
myOffset[0] = myOffset[1] = myOffset[2] = 0;
myActorCollection->Delete();
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+ myMarkerType = (VISU::MarkerType)aResourceMgr->integerValue("VISU", "type_of_marker", 1); // dot
+ myMarkerScale = (VISU::MarkerScale)aResourceMgr->integerValue("VISU", "marker_scale", 9); // 5 pixels
+ myMarkerId = 0;
}
GetPipeLine()->SameAs(anOrigin->GetPipeLine());
anOrigin->GetOffset(myOffset);
+
+ myMarkerType = anOrigin->GetMarkerType();
+ myMarkerScale = anOrigin->GetMarkerScale();
+ myMarkerId = anOrigin->GetMarkerTexture();
+
+ SetForcedHidden(anOrigin->IsForcedHidden());
}
}
if(GetCResult() == theResult)
return;
- if(theResult)
+ if(theResult) {
SetStudyDocument(theResult->GetStudyDocument());
+ }
VISU::TSetModified aModified(this);
aResultEntry = anEntry.in();
}
}
- SetResultEntry(aResultEntry.latin1());
+ SetResultEntry(aResultEntry.toLatin1().data());
if(!GetCResult())
return NULL;
- SetMeshName(VISU::Storable::FindValue(theMap,"myMeshName").latin1());
- SetName(VISU::Storable::FindValue(theMap,"myName").latin1(), false);
+ SetMeshName((const char*)VISU::Storable::FindValue(theMap,"myMeshName").toLatin1());
+ SetName((const char*)VISU::Storable::FindValue(theMap,"myName").toLatin1(), false);
myOffset[0] = VISU::Storable::FindValue(theMap,"myOffset[0]").toFloat();
myOffset[1] = VISU::Storable::FindValue(theMap,"myOffset[1]").toFloat();
myOffset[2] = VISU::Storable::FindValue(theMap,"myOffset[2]").toFloat();
+ myMarkerType = VISU::MarkerType(VISU::Storable::FindValue(theMap,"myMarkerType").toInt());
+ myMarkerScale = VISU::MarkerScale(VISU::Storable::FindValue(theMap,"myMarkerScale").toInt());
+ myMarkerId = VISU::Storable::FindValue(theMap,"myMarkerId").toInt();
myParamsTime.Modified();
return this;
}
VISU::Prs3d_i
::ToStream(std::ostringstream& theStr)
{
- Storable::DataToStream( theStr, "myResultEntry", GetResultEntry() );
- Storable::DataToStream( theStr, "myMeshName", GetCMeshName() );
+ Storable::DataToStream( theStr, "myResultEntry", GetResultEntry().c_str() );
+ Storable::DataToStream( theStr, "myMeshName", GetCMeshName().c_str() );
Storable::DataToStream( theStr, "myName", GetName().c_str() );
Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
+ Storable::DataToStream( theStr, "myMarkerType", int(myMarkerType) );
+ Storable::DataToStream( theStr, "myMarkerScale", int(myMarkerScale) );
+ Storable::DataToStream( theStr, "myMarkerId", myMarkerId );
}
struct TEvent: public TInvokeSignalEvent
{
VISU::Prs3d_i* myRemovable;
-
+
TEvent(const TSignal& theSignal,
VISU::Prs3d_i* theRemovable):
TInvokeSignalEvent(theSignal),
myRemovable(theRemovable)
{}
-
+
virtual
void
Execute()
{
//TInvokeSignalEvent::Execute();
- myRemovable->Destroy();
+ myRemovable->UnRegister();
}
};
::CreateActor(VISU_Actor* theActor)
{
try{
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
Handle(SALOME_InteractiveObject) anIO = GetIO();
if(!anIO.IsNull() && anIO->hasEntry()){
theActor->setIO(anIO);
CheckDataSet();
theActor->SetPrs3d(this);
- theActor->SetShrinkFactor();
+ theActor->SetShrinkFactor(aResourceMgr->integerValue("VISU", "shrink_factor", 80)/100.);
theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
+
+ if( myMarkerType != VISU::MT_USER )
+ theActor->SetMarkerStd( (VTK::MarkerType)myMarkerType, (VTK::MarkerScale)myMarkerScale );
+ else if( myMarkerId > 0 ) {
+ VTK::MarkerTexture aMarkerTexture;
+ if( LoadMarkerTexture( myMarkerId, aMarkerTexture ) )
+ theActor->SetMarkerTexture( myMarkerId, aMarkerTexture );
+ }
+
theActor->SetPipeLine(GetActorPipeLine());
if(theActor->GetPipeLine() != GetPipeLine()){
// To decrease actor'ss pipeline reference counter
}
theActor->SetFactory(this);
- myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,theActor));
- myRemoveActorsFromRendererSignal.connect(boost::bind(&VISU_Actor::RemoveFromRender,theActor));
+ theActor->ConnectToFactory(myUpdateActorsSignal, myRemoveActorsFromRendererSignal);
myActorCollection->AddItem(theActor);
theActor->Delete();
//----------------------------------------------------------------------------
void
VISU::Prs3d_i
-::RemoveActor(VISU_Actor* theActor)
+::RemoveActor(VISU_ActorBase* theActor)
{
if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActor - this = "<<this<<"; theActor = "<<theActor<<"; "<<theActor->GetReferenceCount());
myActorCollection->RemoveItem(theActor);
//----------------------------------------------------------------------------
void
VISU::Prs3d_i
-::UpdateActor(VISU_Actor* theActor)
+::UpdateActor(VISU_ActorBase* theActor)
{
- if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor - this = "<<this<<"; theActor = "<<theActor);
- theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
- theActor->ShallowCopyPL(GetPipeLine());
+ if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(theActor)){
+ if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor - this = "<<this<<"; theActor = "<<anActor);
+ anActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
+
+ if( myMarkerType != VISU::MT_USER )
+ anActor->SetMarkerStd( (VTK::MarkerType)myMarkerType, (VTK::MarkerScale)myMarkerScale );
+ else if( myMarkerId > 0 ) {
+ VTK::MarkerTexture aMarkerTexture;
+ if( LoadMarkerTexture( myMarkerId, aMarkerTexture ) )
+ anActor->SetMarkerTexture( myMarkerId, aMarkerTexture );
+ }
+
+ anActor->ShallowCopyPL(GetPipeLine());
+ anActor->highlight(anActor->isHighlighted());
+ }
}
void
{
if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActors - this = "<<this);
Update();
- CheckDataSet();
+ try {
+ CheckDataSet();
+ } catch( std::exception& ex ) {
+ if( !IsForcedHidden() ) {
+ if( HasVisibleActors() )
+ SetForcedHidden( true );
+ RemoveActors();
+ SUIT_MessageBox::warning( 0,
+ QObject::tr("WRN_VISU"),
+ QString( ex.what() ),
+ QObject::tr("BUT_OK") );
+ }
+ return;
+ }
ProcessVoidEvent(new TInvokeSignalEvent(myUpdateActorsSignal));
}
return GetPipeLine()->GetClippingPlane(theID);
}
+//----------------------------------------------------------------------------
+void VISU::Prs3d_i::RemoveClippingPlane(vtkIdType theID)
+{
+ GetPipeLine()->RemoveClippingPlane(theID);
+}
+
//----------------------------------------------------------------------------
void
VISU::Prs3d_i
{
return myActorCollection->GetNumberOfItems();
}
+
+bool
+VISU::Prs3d_i
+::HasVisibleActors()
+{
+ myActorCollection->InitTraversal();
+ while( vtkActor* anActor = myActorCollection->GetNextActor() )
+ if( VISU_Actor* aVISUActor = dynamic_cast<VISU_Actor*>( anActor ) )
+ if( aVISUActor->GetVisibility() )
+ return true;
+ return false;
+}
+
+bool
+VISU::Prs3d_i
+::IsForcedHidden() const
+{
+ return myIsForcedHidden;
+}
+
+void
+VISU::Prs3d_i
+::SetForcedHidden( bool theFlag )
+{
+ myIsForcedHidden = theFlag;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetMarkerStd(VISU::MarkerType theMarkerType, VISU::MarkerScale theMarkerScale)
+{
+ myMarkerType = theMarkerType;
+ myMarkerScale = theMarkerScale;
+ if( myMarkerType == VISU::MT_POINT_SPRITE )
+ myMarkerScale = VISU::MS_NONE;
+ myParamsTime.Modified();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetMarkerTexture(CORBA::Long theMarkerId)
+{
+ myMarkerType = VISU::MT_USER;
+ myMarkerId = theMarkerId;
+ myParamsTime.Modified();
+}
+
+//----------------------------------------------------------------------------
+VISU::MarkerType
+VISU::Prs3d_i
+::GetMarkerType()
+{
+ return myMarkerType;
+}
+
+//----------------------------------------------------------------------------
+VISU::MarkerScale
+VISU::Prs3d_i
+::GetMarkerScale()
+{
+ return myMarkerScale;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::Prs3d_i
+::GetMarkerTexture()
+{
+ return myMarkerId;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::Prs3d_i
+::LoadMarkerTexture(int theMarkerId, VTK::MarkerTexture& theMarkerTexture)
+{
+ VISU::VISU_Gen_i* aVisuGen = VISU::VISU_Gen_i::GetVisuGenImpl();
+ if( !aVisuGen )
+ return false;
+
+ const VISU::StudyId2MarkerMap& aStudyId2MarkerMap = aVisuGen->GetMarkerMap();
+
+ const SALOMEDS::Study_var& aStudy = GetStudyDocument();
+ if( CORBA::is_nil( aStudy.in() ) )
+ return false;
+
+ int aStudyId = aStudy->StudyId();
+ VISU::StudyId2MarkerMap::const_iterator aStudyId2MarkerIter = aStudyId2MarkerMap.find( aStudyId );
+ if( aStudyId2MarkerIter == aStudyId2MarkerMap.end() )
+ return false;
+
+ VTK::MarkerMap aMarkerMap = aStudyId2MarkerIter->second;
+ VTK::MarkerMap::const_iterator aMarkerIter = aMarkerMap.find( theMarkerId );
+ if( aMarkerIter == aMarkerMap.end() )
+ return false;
+
+ theMarkerTexture = aMarkerIter->second.second;
+ return true;
+}