1 // Copyright (C) 2007-2010 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_ColoredPrs3d_i.hh
25 // Author : Alexey PETROV
28 #ifndef VISU_ColoredPrs3d_i_HeaderFile
29 #define VISU_ColoredPrs3d_i_HeaderFile
31 #include "VISU_Prs3d_i.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_BoostSignals.h"
34 #include "SALOME_GenericObjPointer.hh"
44 //----------------------------------------------------------------------------
45 struct TMinMaxController
49 UpdateReference(ColoredPrs3d_i* theFromPrs3, ColoredPrs3d_i* theToPrs3d);
53 GetComponentMin(vtkIdType theCompID);
57 GetComponentMax(vtkIdType theCompID);
67 typedef SALOME::GenericObjPtr<TMinMaxController> PMinMaxController;
70 //----------------------------------------------------------------------------
71 struct TVTKMinMaxController: virtual TMinMaxController,
78 vtkObjectBase::Register(NULL);
85 vtkObjectBase::Delete();
90 //----------------------------------------------------------------------------
92 CreateDefaultMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d);
95 //----------------------------------------------------------------------------
96 class VISU_I_EXPORT ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d,
97 public virtual TMinMaxController,
98 public virtual TResultObserver,
99 public virtual Prs3d_i
101 ColoredPrs3d_i(const ColoredPrs3d_i&);
104 //----------------------------------------------------------------------------
105 typedef Prs3d_i TSuperClass;
106 typedef VISU::ColoredPrs3d TInterface;
109 The enumeration allow to define what mode should be used for the presentation building.
111 VISU_I_EXPORT enum EPublishInStudyMode {EPublishUnderTimeStamp, EPublishIndependently, ERegisterInCache, EDoNotPublish};
114 ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode);
131 //----------------------------------------------------------------------------
132 //! To update the presentation from result in automatic way
135 UpdateFromResult(Result_i* theResult);
137 //----------------------------------------------------------------------------
140 SetEntity(Entity theEntity);
151 SetFieldName(const char* theFieldName);
158 GetCFieldName() const;
166 SetTimeStampNumber(CORBA::Long theTimeStampNumber);
170 GetTimeStampNumber();
174 GetTimeStampNumberByIndex( CORBA::Long theIndex );
178 GetTimeStampIndexByNumber( CORBA::Long theNumber );
184 VISU::PMinMaxController
185 GetMinMaxController();
188 SetMinMaxController( const VISU::PMinMaxController& theController );
191 SetMinMaxController( ColoredPrs3d_i* theOrigin );
195 GetScalarTimeStampNumber() const;
198 VISU::ColoredPrs3dHolder::TimeStampsRange*
199 GetTimeStampsRange();
207 GetPublishInStudyMode();
209 //----------------------------------------------------------------------------
216 SetScalarMode(CORBA::Long theScalarMode);
228 SetRange(CORBA::Double theMin, CORBA::Double theMax);
232 GetComponentMin(vtkIdType theCompID) = 0;
236 GetComponentMax(vtkIdType theCompID) = 0;
256 SetNbColors(CORBA::Long theNbColors);
264 SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theOrientation);
267 VISU::ColoredPrs3dBase::Orientation
272 SetPosition(CORBA::Double X, CORBA::Double Y);
284 SetSize(CORBA::Double theWidth, CORBA::Double theHeight);
288 SetRatios(CORBA::Long theTitleSize, CORBA::Long theLabelSize,
289 CORBA::Long theBarWidth, CORBA::Long theBarHeight);
317 SetLabels(CORBA::Long theNbLabels);
325 SetLabelsFormat(const char* theFormat);
333 SetTitle(const char* theTitle);
344 SetUnitsVisible(CORBA::Boolean isVisible);
351 * Set the visibility of a distribution curve.
352 * \param theIs is used to switch on/off the visibility of a distribution curve.
354 virtual void SetIsDistributionVisible(CORBA::Boolean theIs);
356 //! Gets current visibility of a distribution curve
357 virtual CORBA::Boolean GetIsDistributionVisible();
359 //! Gets current filtering by scalars mode
360 virtual CORBA::Boolean IsScalarFilterUsed();
362 virtual void UseScalarFiltering( CORBA::Boolean theUseScalarFilter );
365 * Sets scalar range - min and max boundaries of the scalar bar.
366 * \param theMin Min boundary of the scalar bar.
367 * \param theMax Max boundary of the scalar bar.
368 * \param theIsFilter if true then filter by scalars.
372 SetScalarFilterRange( CORBA::Double theMin, CORBA::Double theMax );
374 //----------------------------------------------------------------------------
377 GetScalarFilterMin();
379 //----------------------------------------------------------------------------
382 GetScalarFilterMax();
384 //----------------------------------------------------------------------------
385 //! Gets memory size actually used by the presentation (Mb).
390 //----------------------------------------------------------------------------
391 //! Returns presentation input
392 VISU::ColoredPrs3dHolder::BasicInput*
397 SetHolderEntry(const std::string& theEntry);
403 //! To keep restoring params till the explicit Restore() call
405 SaveRestoringState(SALOMEDS::SObject_ptr theSObject,
406 const Storable::TRestoringMap& theMap);
408 //! To restore the presentation according to the saved state
410 InitFromRestoringState();
412 //----------------------------------------------------------------------------
418 //----------------------------------------------------------------------------
419 //! Sets initial source geometry
422 SetSourceGeometry()=0;
424 //! Add geometry of mesh as group. \retval the id of added group.
427 AddMeshOnGroup(const char* theGroupName)=0;
429 //! Removes all geometries.
434 typedef std::string TGroupName;
435 typedef std::set<TGroupName> TGroupNames;
440 //! Gets number of geometries
444 //----------------------------------------------------------------------------
447 Initlizes the in first time presentation
451 Create(const std::string& theMeshName,
452 VISU::Entity theEntity,
453 const std::string& theFieldName,
454 CORBA::Long theTimeStampNumber);
457 Retores state of the presentation
461 Restore(SALOMEDS::SObject_ptr theSObject,
462 const Storable::TRestoringMap& theMap);
465 Writes persistent params of the presentation into the given stream
469 ToStream(std::ostringstream& theStr);
472 Update state of the presentation according to the input.
476 SameAs(const Prs3d_i* theOrigin);
480 UpdateActor(VISU_ActorBase* theActor);
488 SetBoldTitle(bool isBold);
496 SetItalicTitle(bool isItalic);
504 SetShadowTitle(bool isShadow);
512 SetTitFontType(int theType);
516 GetTitleColor(vtkFloatingPointType& theR,
517 vtkFloatingPointType& theG,
518 vtkFloatingPointType& theB);
522 SetTitleColor(vtkFloatingPointType theR,
523 vtkFloatingPointType theG,
524 vtkFloatingPointType theB);
532 SetBoldLabel(bool isBold);
540 SetItalicLabel(bool isItalic);
548 SetShadowLabel(bool isShadow);
556 SetLblFontType(int theType);
560 GetLabelColor(vtkFloatingPointType& theR,
561 vtkFloatingPointType& theG,
562 vtkFloatingPointType& theB);
566 SetLabelColor(vtkFloatingPointType theR,
567 vtkFloatingPointType theG,
568 vtkFloatingPointType theB);
572 SetMapScale(double theMapScale = 1.0);
575 GetSpecificPL() const
582 GetValLblFontType() const;
586 SetValLblFontType( const int theType );
590 GetValLblFontSize() const;
594 SetValLblFontSize( const double theSize );
598 IsBoldValLbl() const;
602 SetBoldValLbl( const bool theVal );
606 IsItalicValLbl() const;
610 SetItalicValLbl( const bool theVal );
614 IsShadowValLbl() const;
618 SetShadowValLbl( const bool theVal );
622 GetValLblFontColor( vtkFloatingPointType& theR,
623 vtkFloatingPointType& theG,
624 vtkFloatingPointType& theB ) const;
628 SetValLblFontColor( const vtkFloatingPointType theR,
629 const vtkFloatingPointType theG,
630 const vtkFloatingPointType theB );
632 //----------------------------------------------------------------------------
635 Applyes basic input parameters to the presentation.
636 Returns true if all are right.
640 SetInput(bool theReInit);
642 //! Restore input parameters if Apply function fails (redefines Prs3d::OnRestoreInput)
648 Checks whether it is possible to create presentation
649 with the given basic parameters or not.
653 CheckIsPossible() = 0;
656 Creates proper instance of VTK pipeline.
660 CreatePipeLine(VISU_PipeLine* thePipeLine);
663 First checks whether corresponding VTK pipeline exists and create it if not.
664 Then calls VISU_ColoredPrs3d_i::DoSetInput.
665 Returns true if during the call corresponding VTK pipeline was created,
670 OnSetInput(bool theReInit);
673 Sets input data set according to basic input parameters -
674 Result, MeshName, Entity, FieldName and TimeStampNumber.
678 DoSetInput(bool theIsInitilizePipe, bool theReInit) = 0;
681 The enumeration allow to define what mode should be used for the presentation building.
683 enum EBuildMode {ECreateNew, ESameAs, ERestore};
686 The enumeration allow to define what mode should be used for the presentation building.
689 Build(EBuildMode theBuildMode);
693 SetField(VISU::PField theField);
696 UseFixedRange(bool theUseFixedRange);
701 //! Used in derived classes to initilize the IO for actors
706 TGroupNames myGroupNames;
710 Storable::TRestoringMap myRestoringMap;
711 SALOMEDS::SObject_var myRestoringSObject;
713 // Decalare basic input parameters
714 VISU::Entity myEntity;
715 VISU::Entity myPreviousEntity;
717 std::string myFieldName;
718 std::string myPreviousFieldName;
720 CORBA::Long myTimeStampNumber;
721 CORBA::Long myPreviousTimeStampNumber;
723 boost::signalslib::connection myResultConnection;
725 bool myIsTimeStampFixed;
728 PMinMaxController myMinMaxController;
729 EPublishInStudyMode myPublishInStudyMode;
731 std::string myHolderEntry;
734 std::string myScalarBarTitle;
737 int myNumberOfLabels;
738 std::string myLabelsFormat;
740 VISU::ColoredPrs3dBase::Orientation myOrientation;
741 vtkFloatingPointType myPosition[2],
743 myTitleSize, myLabelSize,
744 myBarWidth, myBarHeight;
748 bool myIsItalicTitle;
749 bool myIsShadowTitle;
751 vtkFloatingPointType myTitleColor[3];
754 bool myIsItalicLabel;
755 bool myIsShadowLabel;
757 vtkFloatingPointType myLabelColor[3];
759 VISU_ColoredPL* myColoredPL;
762 bool myIsDistributionVisible; // RKV
765 int myValLblFontType;
766 double myValLblFontSize;
768 bool myIsItalicValLbl;
769 bool myIsShadowValLbl;
770 vtkFloatingPointType myValLblFontColor[ 3 ];
774 //----------------------------------------------------------------------------
775 template<class TColoredPrs3d>
777 StorableEngine(SALOMEDS::SObject_ptr theSObject,
778 const Storable::TRestoringMap& theMap,
779 const std::string& thePrefix,
780 CORBA::Boolean theIsMultiFile)
782 TColoredPrs3d* aColoredPrs3d = new TColoredPrs3d(ColoredPrs3d_i::EDoNotPublish);
783 return aColoredPrs3d->Restore(theSObject, theMap);
787 //----------------------------------------------------------------------------