1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_ColoredPrs3d_i.hh
24 // Author : Alexey PETROV
27 #ifndef VISU_ColoredPrs3d_i_HeaderFile
28 #define VISU_ColoredPrs3d_i_HeaderFile
30 #include "VISU_Prs3d_i.hh"
31 #include "VISU_Result_i.hh"
32 #include "VISU_BoostSignals.h"
33 #include "SALOME_GenericObjPointer.hh"
43 //----------------------------------------------------------------------------
44 struct TMinMaxController
48 UpdateReference(ColoredPrs3d_i* theFromPrs3, ColoredPrs3d_i* theToPrs3d);
52 GetComponentMin(vtkIdType theCompID);
56 GetComponentMax(vtkIdType theCompID);
66 typedef SALOME::GenericObjPtr<TMinMaxController> PMinMaxController;
69 //----------------------------------------------------------------------------
70 struct TVTKMinMaxController: virtual TMinMaxController,
77 vtkObjectBase::Register(NULL);
84 vtkObjectBase::Delete();
89 //----------------------------------------------------------------------------
91 CreateDefaultMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d);
94 //----------------------------------------------------------------------------
95 class VISU_I_EXPORT ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d,
96 public virtual TMinMaxController,
97 public virtual TResultObserver,
98 public virtual Prs3d_i
100 ColoredPrs3d_i(const ColoredPrs3d_i&);
103 //----------------------------------------------------------------------------
104 typedef Prs3d_i TSuperClass;
105 typedef VISU::ColoredPrs3d TInterface;
108 The enumeration allow to define what mode should be used for the presentation building.
110 VISU_I_EXPORT enum EPublishInStudyMode {EPublishUnderTimeStamp, EPublishIndependently, ERegisterInCache, EDoNotPublish};
113 ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode);
130 //----------------------------------------------------------------------------
131 //! To update the presentation from result in automatic way
134 UpdateFromResult(Result_i* theResult);
136 //----------------------------------------------------------------------------
139 SetEntity(Entity theEntity);
150 SetFieldName(const char* theFieldName);
157 GetCFieldName() const;
165 SetTimeStampNumber(CORBA::Long theTimeStampNumber);
169 GetTimeStampNumber();
173 GetTimeStampNumberByIndex( CORBA::Long theIndex );
177 GetTimeStampIndexByNumber( CORBA::Long theNumber );
183 VISU::PMinMaxController
184 GetMinMaxController();
187 SetMinMaxController( const VISU::PMinMaxController& theController );
190 SetMinMaxController( ColoredPrs3d_i* theOrigin );
194 GetScalarTimeStampNumber() const;
197 VISU::ColoredPrs3dHolder::TimeStampsRange*
198 GetTimeStampsRange();
206 GetPublishInStudyMode();
208 //----------------------------------------------------------------------------
215 SetScalarMode(CORBA::Long theScalarMode);
227 SetRange(CORBA::Double theMin, CORBA::Double theMax);
231 GetComponentMin(vtkIdType theCompID) = 0;
235 GetComponentMax(vtkIdType theCompID) = 0;
255 SetNbColors(CORBA::Long theNbColors);
263 SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation);
266 VISU::ColoredPrs3dBase::Orientation
271 SetPosition(CORBA::Double X, CORBA::Double Y);
283 SetSize(CORBA::Double theWidth, CORBA::Double theHeight);
287 SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize,
288 CORBA::Long theBarWidth, CORBA::Long theBarHeight);
316 SetLabels(CORBA::Long theNbLabels);
324 SetLabelsFormat(const char* theFormat);
332 SetTitle(const char* theTitle);
343 SetUnitsVisible(CORBA::Boolean isVisible);
350 * Set the visibility of a distribution curve.
351 * \param theIs is used to switch on/off the visibility of a distribution curve.
353 virtual void SetIsDistributionVisible(CORBA::Boolean theIs);
355 //! Gets current visibility of a distribution curve
356 virtual CORBA::Boolean GetIsDistributionVisible();
358 //! Gets current filtering by scalars mode
359 virtual CORBA::Boolean IsScalarFilterUsed();
361 virtual void UseScalarFiltering( CORBA::Boolean theUseScalarFilter );
364 * Sets scalar range - min and max boundaries of the scalar bar.
365 * \param theMin Min boundary of the scalar bar.
366 * \param theMax Max boundary of the scalar bar.
367 * \param theIsFilter if true then filter by scalars.
371 SetScalarFilterRange( CORBA::Double theMin, CORBA::Double theMax );
373 //----------------------------------------------------------------------------
376 GetScalarFilterMin();
378 //----------------------------------------------------------------------------
381 GetScalarFilterMax();
383 //----------------------------------------------------------------------------
384 //! Gets memory size actually used by the presentation (Mb).
389 //----------------------------------------------------------------------------
390 //! Returns presentation input
391 VISU::ColoredPrs3dHolder::BasicInput*
396 SetHolderEntry(const std::string& theEntry);
402 //! To keep restoring params till the explicit Restore() call
404 SaveRestoringState(SALOMEDS::SObject_ptr theSObject,
405 const Storable::TRestoringMap& theMap);
407 //! To restore the presentation according to the saved state
409 InitFromRestoringState();
411 //----------------------------------------------------------------------------
417 //----------------------------------------------------------------------------
418 //! Sets initial source geometry
421 SetSourceGeometry()=0;
423 //! Add geometry of mesh as group. \retval the id of added group.
426 AddMeshOnGroup(const char* theGroupName)=0;
428 //! Removes all geometries.
433 typedef std::string TGroupName;
434 typedef std::set<TGroupName> TGroupNames;
439 //! Gets number of geometries
443 //----------------------------------------------------------------------------
446 Initlizes the in first time presentation
450 Create(const std::string& theMeshName,
451 VISU::Entity theEntity,
452 const std::string& theFieldName,
453 CORBA::Long theTimeStampNumber);
456 Retores state of the presentation
460 Restore(SALOMEDS::SObject_ptr theSObject,
461 const Storable::TRestoringMap& theMap);
464 Writes persistent params of the presentation into the given stream
468 ToStream(std::ostringstream& theStr);
471 Update state of the presentation according to the input.
475 SameAs(const Prs3d_i* theOrigin);
479 UpdateActor(VISU_ActorBase* theActor);
487 SetBoldTitle(bool isBold);
495 SetItalicTitle(bool isItalic);
503 SetShadowTitle(bool isShadow);
511 SetTitFontType(int theType);
515 GetTitleColor(vtkFloatingPointType& theR,
516 vtkFloatingPointType& theG,
517 vtkFloatingPointType& theB);
521 SetTitleColor(vtkFloatingPointType theR,
522 vtkFloatingPointType theG,
523 vtkFloatingPointType theB);
531 SetBoldLabel(bool isBold);
539 SetItalicLabel(bool isItalic);
547 SetShadowLabel(bool isShadow);
555 SetLblFontType(int theType);
559 GetLabelColor(vtkFloatingPointType& theR,
560 vtkFloatingPointType& theG,
561 vtkFloatingPointType& theB);
565 SetLabelColor(vtkFloatingPointType theR,
566 vtkFloatingPointType theG,
567 vtkFloatingPointType theB);
571 SetMapScale(double theMapScale = 1.0);
574 GetSpecificPL() const
581 GetValLblFontType() const;
585 SetValLblFontType( const int theType );
589 GetValLblFontSize() const;
593 SetValLblFontSize( const double theSize );
597 IsBoldValLbl() const;
601 SetBoldValLbl( const bool theVal );
605 IsItalicValLbl() const;
609 SetItalicValLbl( const bool theVal );
613 IsShadowValLbl() const;
617 SetShadowValLbl( const bool theVal );
621 GetValLblFontColor( vtkFloatingPointType& theR,
622 vtkFloatingPointType& theG,
623 vtkFloatingPointType& theB ) const;
627 SetValLblFontColor( const vtkFloatingPointType theR,
628 const vtkFloatingPointType theG,
629 const vtkFloatingPointType theB );
631 //----------------------------------------------------------------------------
634 Applyes basic input parameters to the presentation.
635 Returns true if all are right.
639 SetInput(bool theReInit);
641 //! Restore input parameters if Apply function fails (redefines Prs3d::OnRestoreInput)
647 Checks whether it is possible to create presentation
648 with the given basic parameters or not.
652 CheckIsPossible() = 0;
655 Creates proper instance of VTK pipeline.
659 CreatePipeLine(VISU_PipeLine* thePipeLine);
662 First checks whether corresponding VTK pipeline exists and create it if not.
663 Then calls VISU_ColoredPrs3d_i::DoSetInput.
664 Returns true if during the call corresponding VTK pipeline was created,
669 OnSetInput(bool theReInit);
672 Sets input data set according to basic input parameters -
673 Result, MeshName, Entity, FieldName and TimeStampNumber.
677 DoSetInput(bool theIsInitilizePipe, bool theReInit) = 0;
680 The enumeration allow to define what mode should be used for the presentation building.
682 enum EBuildMode {ECreateNew, ESameAs, ERestore};
685 The enumeration allow to define what mode should be used for the presentation building.
688 Build(EBuildMode theBuildMode);
692 SetField(VISU::PField theField);
695 UseFixedRange(bool theUseFixedRange);
700 //! Used in derived classes to initilize the IO for actors
705 TGroupNames myGroupNames;
709 Storable::TRestoringMap myRestoringMap;
710 SALOMEDS::SObject_var myRestoringSObject;
712 // Decalare basic input parameters
713 VISU::Entity myEntity;
714 VISU::Entity myPreviousEntity;
716 std::string myFieldName;
717 std::string myPreviousFieldName;
719 CORBA::Long myTimeStampNumber;
720 CORBA::Long myPreviousTimeStampNumber;
722 boost::signalslib::connection myResultConnection;
724 bool myIsTimeStampFixed;
727 PMinMaxController myMinMaxController;
728 EPublishInStudyMode myPublishInStudyMode;
730 std::string myHolderEntry;
733 std::string myScalarBarTitle;
736 int myNumberOfLabels;
737 std::string myLabelsFormat;
739 VISU::ColoredPrs3dBase::Orientation myOrientation;
740 vtkFloatingPointType myPosition[2],
742 myTitleSize, myLabelSize,
743 myBarWidth, myBarHeight;
747 bool myIsItalicTitle;
748 bool myIsShadowTitle;
750 vtkFloatingPointType myTitleColor[3];
753 bool myIsItalicLabel;
754 bool myIsShadowLabel;
756 vtkFloatingPointType myLabelColor[3];
758 VISU_ColoredPL* myColoredPL;
761 bool myIsDistributionVisible; // RKV
764 int myValLblFontType;
765 double myValLblFontSize;
767 bool myIsItalicValLbl;
768 bool myIsShadowValLbl;
769 vtkFloatingPointType myValLblFontColor[ 3 ];
773 //----------------------------------------------------------------------------
774 template<class TColoredPrs3d>
776 StorableEngine(SALOMEDS::SObject_ptr theSObject,
777 const Storable::TRestoringMap& theMap,
778 const std::string& thePrefix,
779 CORBA::Boolean theIsMultiFile)
781 TColoredPrs3d* aColoredPrs3d = new TColoredPrs3d(ColoredPrs3d_i::EDoNotPublish);
782 return aColoredPrs3d->Restore(theSObject, theMap);
786 //----------------------------------------------------------------------------