1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // VISU OBJECT : interactive object for VISU entities implementation
21 // File : VISU_PointMap3d_i.cc
22 // Author : Dmitry Matveitchev
25 #include "VISU_PointMap3d_i.hh"
27 #include "VISU_CutLinesBase_i.hh"
28 #include "VISU_CutSegment_i.hh"
29 #include "VISU_Result_i.hh"
30 #include "VISU_ViewManager_i.hh"
31 #include "VISU_ScalarBarActor.hxx"
32 #include "SUIT_ResourceMgr.h"
34 #include "SALOME_Event.h"
35 #include "VISU_Prs3dUtils.hh"
36 #include "SPlot2d_Curve.h"
37 #include "VISU_PipeLineUtils.hxx"
39 #include "VISU_TableReader.hxx"
40 #include "VISU_ConvertorUtils.hxx"
41 #include "VISU_DeformedGridPL.hxx"
43 #include "SALOME_InteractiveObject.hxx"
44 #include "VISU_Gen_i.hh"
46 #include <vtkTextProperty.h>
47 #include <vtkActorCollection.h>
49 #include <boost/bind.hpp>
52 static int MYDEBUG = 0;
54 static int MYDEBUG = 0;
59 //----------------------------------------------------------------
61 //----------------------------------------------------------------
62 int VISU::PointMap3d_i::myNbPresent = 0;
63 const string VISU::PointMap3d_i::myComment = "POINTMAP3D";
67 QString VISU::PointMap3d_i::GenerateName()
69 return VISU::GenerateName( "Table3D - ", ++myNbPresent );
74 const char* VISU::PointMap3d_i::GetComment() const
76 return myComment.c_str();
81 VISU::PointMap3d_i::PointMap3d_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry )
82 : Table_i(theStudy, theObjectEntry),
83 myActorCollection(vtkActorCollection::New()),
86 if(MYDEBUG) MESSAGE("PointMap3d_i::PointMap3d_i - this = "<<this);
87 SetStudyDocument(theStudy);
88 mySObj = theStudy->FindObjectID(theObjectEntry);
89 myOffset[0] = myOffset[1] = myOffset[2] = 0;
90 myActorCollection->Delete();
95 VISU::PointMap3d_i::~PointMap3d_i()
97 if(MYDEBUG) MESSAGE("PointMap3d_i::~PointMap3d_i - this = "<<this);
100 //----------------------------------------------------------------------------
103 struct TInvokeSignalEvent: public SALOME_Event
105 typedef boost::signal0<void> TSignal;
106 const TSignal& mySignal;
108 TInvokeSignalEvent(const TSignal& theSignal):
121 //----------------------------------------------------------------------------
124 ::SetTitle( const char* theTitle )
126 SetName( theTitle, true );
129 //----------------------------------------------------------------------------
134 return CORBA::string_dup( GetName().c_str() );
137 //----------------------------------------------------------------------------
138 SALOMEDS::SObject_var
145 //----------------------------------------------------------------------------
150 CORBA::String_var anEntry = mySObj->GetID();
154 //----------------------------------------------------------------------------
155 Handle(SALOME_InteractiveObject)
160 myIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str());
165 //----------------------------------------------------------------------------
167 Creates table3d object
169 VISU::Storable* VISU::PointMap3d_i::Create()
172 SetName(GetTableTitle().toLatin1().constData(), false);
174 if ( GetName() == "" ) {
175 if ( !mySObj->_is_nil() ) {
176 CutLinesBase_i* pCutLines = NULL;
177 CORBA::Object_var anObj = SObjectToObject(mySObj);
178 if(!CORBA::is_nil(anObj)){
179 VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
180 if(!aCutLines->_is_nil())
181 pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
184 if (mySObj->GetName()) SetName(mySObj->GetName(), false);
188 if ( GetName() == "" )
189 SetName(GenerateName().toLatin1().constData(), false);
192 myTablePL = VISU_DeformedGridPL::New();
193 myTablePL->SetPolyDataIDMapper(GetTableIDMapper());
196 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
198 bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true );
199 SetUnitsVisible(isUnits);
203 if( aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false) )
204 SetScaling(VISU::LOGARITHMIC);
206 SetScaling(VISU::LINEAR);
208 int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 );
209 SetNbColors(aNumberOfColors);
211 int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
212 UseFixedRange(aRangeType == 1);
214 float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0);
215 float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0);
216 SetRange(aMin, aMax);
219 int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 );
220 SetLabelsFormat( VISU::ToFormat( lp ).c_str() );
223 int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
224 if(anOrientation == 1)
225 SetBarOrientation(VISU::ColoredPrs3dBase::HORIZONTAL);
227 SetBarOrientation(VISU::ColoredPrs3dBase::VERTICAL);
230 QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" );
232 vtkFloatingPointType aXorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.2;
233 aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin);
234 myPosition[0] = aXorigin;
236 vtkFloatingPointType aYorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.012;
237 aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin);
238 myPosition[1] = aYorigin;
241 myWidth = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.1 : 0.6;
242 myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth);
244 myHeight = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12;
245 myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
247 myTitleSize = aResourceMgr->doubleValue("VISU", propertyName + "title_size", 0);
248 myLabelSize = aResourceMgr->doubleValue("VISU", propertyName + "label_size", 0);
249 myBarWidth = aResourceMgr->doubleValue("VISU", propertyName + "bar_width", 0);
250 myBarHeight = aResourceMgr->doubleValue("VISU", propertyName + "bar_height", 0);
253 myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 );
255 // Fonts properties definition
256 myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true;
257 myTitFontType = VTK_ARIAL;
259 if(aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" )){
260 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
261 if ( f.family() == "Arial" )
262 myTitFontType = VTK_ARIAL;
263 else if ( f.family() == "Courier" )
264 myTitFontType = VTK_COURIER;
265 else if ( f.family() == "Times" )
266 myTitFontType = VTK_TIMES;
268 myIsBoldTitle = f.bold();
269 myIsItalicTitle = f.italic();
270 myIsShadowTitle = f.overline();
273 QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
275 myTitleColor[0] = aTextColor.red() / 255;
276 myTitleColor[1] = aTextColor.green() / 255;
277 myTitleColor[2] = aTextColor.blue() / 255;
279 myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true;
280 myLblFontType = VTK_ARIAL;
282 if( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" )){
283 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
284 if ( f.family() == "Arial" )
285 myLblFontType = VTK_ARIAL;
286 else if ( f.family() == "Courier" )
287 myLblFontType = VTK_COURIER;
288 else if ( f.family() == "Times" )
289 myLblFontType = VTK_TIMES;
291 myIsBoldLabel = f.bold();
292 myIsItalicLabel = f.italic();
293 myIsShadowLabel = f.overline();
296 QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
298 myLabelColor[0] = aLabelColor.red() / 255;
299 myLabelColor[1] = aLabelColor.green() / 255;
300 myLabelColor[2] = aLabelColor.blue() / 255;
302 // scalar bar default position
303 bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
306 aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
308 if(myBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL){
309 myPosition[1] += myHeight*(aPlace-1);
311 myPosition[0] += myWidth*(aPlace-1);
314 return Build( false );
325 //Initialisate table mapper
326 SALOMEDS::GenericAttribute_var anAttr;
327 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
328 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
330 PTableIDMapper aTableIDMapper( new TTableIDMapper() );
331 TTable2D& aTable2D = *aTableIDMapper;
333 aTable2D.myTitle = aTableOfReal->GetTitle();
335 SALOMEDS::StringSeq_var aColStrList = aTableOfReal->GetColumnTitles();
336 SALOMEDS::StringSeq_var aRowStrList = aTableOfReal->GetRowTitles();
338 for ( int i = 0; i < aRowStrList->length(); i++ ) {
339 aTable2D.myColumnTitles.push_back( aRowStrList[ i ].in() );
342 int aCols = aTableOfReal->GetNbColumns();
343 int aRows = aTableOfReal->GetNbRows();
345 for (int i=1; i<=aCols; i++) {
347 aRow.myTitle = aColStrList[ i-1 ].in();
348 for (int j=1; j<=aRows; j++) {
349 double aVal = aTableOfReal->GetValue(j, i);
350 QString aValStr = QString::number(aVal);
351 aRow.myValues.push_back( aValStr.toLatin1().constData() );
353 if( aRow.myValues.size() > 0 )
354 aTable2D.myRows.push_back( aRow );
357 return aTableIDMapper;
363 VISU_PointMap3dActor* VISU::PointMap3d_i::CreateActor()
365 VISU_PointMap3dActor* anActor = VISU_PointMap3dActor::New();
366 anActor->SetPipeLine(myTablePL);
367 anActor->SetFactory(this);
369 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
370 int aDispMode = aResourceMgr->integerValue("VISU", "point_map_represent", 2);
371 bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_map_shrink", false);
372 anActor->SetRepresentation(aDispMode);
373 if (toShrink) anActor->SetShrink();
375 Handle (SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str());
376 anActor->setIO(anIO);
378 myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,anActor));
379 // myRemoveActorsFromRendererSignal.connect(boost::bind(&VISU_Actor::RemoveFromRender,anActor));
381 myActorCollection->AddItem(anActor);
383 UpdateActor( anActor );
391 void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor)
393 if(VISU_PointMap3dActor* anActor = dynamic_cast<VISU_PointMap3dActor*>(theActor)){
395 VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
396 aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable());
397 aScalarBar->SetTitle(GetTitle());
398 aScalarBar->SetOrientation(GetBarOrientation());
399 aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
400 aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY());
401 aScalarBar->SetWidth(GetWidth());
402 aScalarBar->SetHeight(GetHeight());
403 aScalarBar->SetNumberOfLabels(GetLabels());
404 aScalarBar->SetRatios(myTitleSize, myLabelSize,
405 myBarWidth, myBarHeight);
406 aScalarBar->SetNumberOfLabels(GetLabels());
407 aScalarBar->SetLabelFormat(GetLabelsFormat());
409 vtkFloatingPointType anRGB[3];
411 vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
412 aTitleProp->SetFontFamily(GetTitFontType());
414 GetTitleColor(anRGB[0],anRGB[1],anRGB[2]);
415 aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
417 IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
418 IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
419 IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
421 vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
422 aLabelProp->SetFontFamily(GetLblFontType());
424 GetLabelColor(anRGB[0],anRGB[1],anRGB[2]);
425 aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
427 IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
428 IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
429 IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
431 aScalarBar->Modified();
433 theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
440 if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActors - this = "<<this);
441 ProcessVoidEvent(new TVoidMemFunEvent<VISU_PipeLine>
442 (GetSpecificPL(), &VISU_PipeLine::Update));
444 ProcessVoidEvent(new VISU::TInvokeSignalEvent(myUpdateActorsSignal));
447 //----------------------------------------------------------------------------
452 if(GetMTime() < myUpdateTime.GetMTime())
455 if(MYDEBUG) MESSAGE("PointMap3d_i::Update - this = "<<this);
458 ProcessVoidEvent(new TVoidMemFunEvent<VISU_PipeLine>
459 (GetSpecificPL(), &VISU_PipeLine::Update));
460 myUpdateTime.Modified();
461 }catch(std::exception&){
464 throw std::runtime_error("PointMap3d_i::Update >> unexpected exception was caught!!!");
468 //----------------------------------------------------------------------------
473 unsigned long int aTime = myParamsTime.GetMTime();
474 if( GetSpecificPL() )
475 aTime = std::max(aTime, GetSpecificPL()->GetMTime());
480 Builds presentation of table
482 VISU::Storable* VISU::PointMap3d_i::Build( int theRestoring )
485 // look for reference SObject with table attribute
486 SALOMEDS::SObject_var SO = mySObj;
488 if ( !SO->_is_nil() ) {
489 CutLinesBase_i* pCutLines = NULL;
490 CORBA::Object_var anObj = SObjectToObject(SO);
491 if(!CORBA::is_nil(anObj)){
492 VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
493 if(!aCutLines->_is_nil())
494 pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
496 SALOMEDS::Study_var aStudy = GetStudyDocument();
497 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
498 SALOMEDS::GenericAttribute_var anAttr;
499 // look for component
500 if ( !theRestoring ) {
501 SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
502 // create SObject and set attributes
505 aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment());
507 aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment());
508 SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
509 if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
510 SALOMEDS::AttributeString_var aCommentAttr =
511 SALOMEDS::AttributeString::_narrow(anAttr);
512 CORBA::String_var aValue = aCommentAttr->Value();
513 Storable::TRestoringMap aMap;
514 Storable::StringToMap(aValue.in(),aMap);
516 QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
518 if(aMethodName == "ImportTables"){
519 aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment());
525 string anEntry = CreateAttributes( GetStudyDocument(),
526 SO->GetID(),//SComponent->GetID(),
531 aComment.toLatin1().constData(),
533 // create SObject referenced to real table object
534 mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
536 bool isCutSegment = dynamic_cast<CutSegment_i*>(pCutLines);
537 pCutLines->BuildTableOfReal(mySObj, isCutSegment);
539 // mpv (PAL5357): reference attributes are unnecessary now
540 //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
541 //Builder->Addreference( refSO, SO );
549 Restores table object from stream
551 VISU::Storable* VISU::PointMap3d_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO)
553 VISU::Table_i::Restore( theMap, SO);
554 if(MYDEBUG) MESSAGE(GetComment());
555 SetName(VISU::Storable::FindValue(theMap,"myName").toLatin1().constData(), false);
556 myTitle = VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData();
557 myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() );
558 mySObj = SALOMEDS::SObject::_duplicate(SO);
561 myTablePL = VISU_DeformedGridPL::New();
562 myTablePL->SetPolyDataIDMapper(GetTableIDMapper());
565 //Restore Other Values
567 float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
568 float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
569 SetRange(aMin, aMax);
571 UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt());
573 SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
574 SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt());
575 SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g").toLatin1().constData());
576 SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myBarOrientation").toInt());
578 SetTitle(VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData());
579 myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
580 myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
581 myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
582 myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
583 myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
584 myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt();
585 myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt();
586 myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
587 myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
589 myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
590 myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
591 myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
592 myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
593 myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
594 myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
595 myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
597 myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
598 myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
599 myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
600 myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
601 myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
602 myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
603 myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
605 myParamsTime.Modified();
606 return Build( true );
609 Flushes table data into stream
611 void VISU::PointMap3d_i::ToStream( std::ostringstream& theStr )
613 Storable::DataToStream( theStr, "myName", GetName().c_str() );
614 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
615 Storable::DataToStream( theStr, "myOrientation", myOrientation );
617 Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
618 Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
619 Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
621 Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
622 Storable::DataToStream( theStr, "myBarOrientation", myBarOrientation );
624 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
625 Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
626 Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
627 Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
628 Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
629 Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
630 Storable::DataToStream( theStr, "myWidth", myWidth );
631 Storable::DataToStream( theStr, "myHeight", myHeight );
632 Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
633 Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
634 Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
635 Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
637 Storable::DataToStream( theStr, "myTitFontType", myTitFontType );
638 Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle );
639 Storable::DataToStream( theStr, "myIsItalicTitle", myIsItalicTitle );
640 Storable::DataToStream( theStr, "myIsShadowTitle", myIsShadowTitle );
641 Storable::DataToStream( theStr, "myTitleColor[0]", myTitleColor[0] );
642 Storable::DataToStream( theStr, "myTitleColor[1]", myTitleColor[1] );
643 Storable::DataToStream( theStr, "myTitleColor[2]", myTitleColor[2] );
645 Storable::DataToStream( theStr, "myLblFontType", myLblFontType );
646 Storable::DataToStream( theStr, "myIsBoldLabel", myIsBoldLabel );
647 Storable::DataToStream( theStr, "myIsItalicLabel", myIsItalicLabel );
648 Storable::DataToStream( theStr, "myIsShadowLabel", myIsShadowLabel );
649 Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] );
650 Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] );
651 Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] );
654 Called from engine to restore table from the file
656 VISU::Storable* VISU::PointMap3d_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
657 const Storable::TRestoringMap& theMap,
658 const std::string& thePrefix,
659 CORBA::Boolean theIsMultiFile)
661 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
662 VISU::PointMap3d_i* pResent = new VISU::PointMap3d_i( aStudy, "" );
663 return pResent->Restore( theMap, theSObject);
666 Gets title for the original table object
668 QString VISU::PointMap3d_i::GetTableTitle()
670 SALOMEDS::SObject_var SO = mySObj;
671 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
672 SALOMEDS::GenericAttribute_var anAttr;
673 SALOMEDS::AttributeTableOfInteger_var anInt;
674 SALOMEDS::AttributeTableOfReal_var aReal;
675 if ( !SO->_is_nil() ) {
676 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
677 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
678 CORBA::String_var aString = anInt->GetTitle();
681 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
682 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
683 CORBA::String_var aString = aReal->GetTitle();
690 //---------------------------------------------------------------
691 void VISU::PointMap3d_i::RemoveFromStudy()
693 struct TRemoveFromStudy: public SALOME_Event
695 VISU::PointMap3d_i* myRemovable;
696 TRemoveFromStudy(VISU::PointMap3d_i* theRemovable):
697 myRemovable(theRemovable)
704 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
708 // Remove the table with all curves
709 ProcessVoidEvent(new TRemoveFromStudy(this));
712 //----------------------------------------------------------------
713 void VISU::PointMap3d_i::SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz)
715 VISU::TSetModified aModified(this);
719 myParamsTime.Modified();
722 void VISU::PointMap3d_i::GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz)
729 void VISU::PointMap3d_i::SetMarkerStd(VISU::MarkerType, VISU::MarkerScale)
733 void VISU::PointMap3d_i::SetMarkerTexture(CORBA::Long)
737 VISU::MarkerType VISU::PointMap3d_i::GetMarkerType()
739 return VISU::MT_NONE;
742 VISU::MarkerScale VISU::PointMap3d_i::GetMarkerScale()
744 return VISU::MS_NONE;
747 CORBA::Long VISU::PointMap3d_i::GetMarkerTexture()
752 CORBA::Float VISU::PointMap3d_i::GetMemorySize()
754 CORBA::Float aSize = GetSpecificPL()->GetMemorySize();
756 int anEnd = myActorCollection->GetNumberOfItems();
757 for(int anId = 0; anId < anEnd; anId++)
758 if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
759 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
760 aSize += anActor->GetMemorySize();
761 //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
764 // Convert to mega bytes
765 return aSize / (1024.0 * 1024.0);
768 //------------------ ColoredPrs3dBase Methods --------------------
769 CORBA::Double VISU::PointMap3d_i::GetMin()
771 return myTablePL->GetScalarRange()[0];
774 CORBA::Double VISU::PointMap3d_i::GetMinTableValue()
776 SALOMEDS::GenericAttribute_var anAttr;
777 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
778 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
779 double aMin = aTableOfReal->GetValue(1, 1);
781 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
782 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
783 double aVal = aTableOfReal->GetValue(j, i);
791 CORBA::Double VISU::PointMap3d_i::GetMaxTableValue()
793 SALOMEDS::GenericAttribute_var anAttr;
794 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
795 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
796 double aMax = aTableOfReal->GetValue(1, 1);
798 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
799 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
800 double aVal = aTableOfReal->GetValue(j, i);
808 CORBA::Double VISU::PointMap3d_i::GetMax()
810 return myTablePL->GetScalarRange()[1];
813 void VISU::PointMap3d_i::SetRange(CORBA::Double theMin, CORBA::Double theMax)
815 vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
816 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType*>
817 (GetSpecificPL(), &VISU_DeformedGridPL::SetScalarRange, aScalarRange));
822 CORBA::Double VISU::PointMap3d_i::GetSourceMin()
824 vtkFloatingPointType aRange[2];
825 GetSpecificPL()->GetSourceRange(aRange);
829 CORBA::Double VISU::PointMap3d_i::GetSourceMax()
831 vtkFloatingPointType aRange[2];
832 GetSpecificPL()->GetSourceRange(aRange);
836 void VISU::PointMap3d_i::SetSourceRange()
838 GetSpecificPL()->SetSourceRange();
839 ProcessVoidEvent(new TVoidMemFunEvent<VISU_DeformedGridPL>
840 (GetSpecificPL(), &VISU_DeformedGridPL::SetSourceRange));
842 UseFixedRange(false);
845 CORBA::Boolean VISU::PointMap3d_i::IsRangeFixed()
847 return myIsFixedRange;
850 void VISU::PointMap3d_i::UseFixedRange(bool theRange)
852 if(myIsFixedRange == theRange)
855 myIsFixedRange = theRange;
858 void VISU::PointMap3d_i::SetPosition(CORBA::Double theX, CORBA::Double theY)
860 bool anIsSameValue = VISU::CheckIsSameValue(myPosition[0], theX);
861 anIsSameValue &= VISU::CheckIsSameValue(myPosition[1], theY);
865 myPosition[0] = theX;
866 myPosition[1] = theY;
867 myParamsTime.Modified();
870 CORBA::Double VISU::PointMap3d_i::GetPosX()
872 return myPosition[0];
875 CORBA::Double VISU::PointMap3d_i::GetPosY()
877 return myPosition[1];
880 void VISU::PointMap3d_i::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
882 bool anIsSameValue = VISU::CheckIsSameValue(myWidth, theWidth);
883 anIsSameValue &= VISU::CheckIsSameValue(myHeight, theHeight);
888 myHeight = theHeight;
889 myParamsTime.Modified();
892 CORBA::Double VISU::PointMap3d_i::GetHeight()
897 CORBA::Double VISU::PointMap3d_i::GetWidth()
902 void VISU::PointMap3d_i::SetNbColors(CORBA::Long theNbColors)
904 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
905 (GetSpecificPL(), &VISU_DeformedGridPL::SetNbColors, theNbColors));
908 CORBA::Long VISU::PointMap3d_i::GetNbColors()
910 return GetSpecificPL()->GetNbColors();
913 void VISU::PointMap3d_i::SetLabels(CORBA::Long theNbLabels)
915 if(myNumberOfLabels == theNbLabels)
918 myNumberOfLabels = theNbLabels;
921 CORBA::Long VISU::PointMap3d_i::GetLabels()
923 return myNumberOfLabels;
926 void VISU::PointMap3d_i::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theBarOrientation)
928 if(myBarOrientation == theBarOrientation)
931 if ( ( theBarOrientation == VISU::ColoredPrs3dBase::VERTICAL && myHeight < myWidth ) ||
932 ( theBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL && myHeight > myWidth ) ) {
933 vtkFloatingPointType tmp = myHeight;
938 myBarOrientation = theBarOrientation;
939 myParamsTime.Modified();
942 VISU::ColoredPrs3dBase::Orientation VISU::PointMap3d_i::GetBarOrientation()
944 return myBarOrientation;
947 //------------------- ScaledPrs3d Methods -----------------------
949 void VISU::PointMap3d_i::SetScaling(VISU::Scaling theScaling)
951 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
952 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaling, theScaling));
955 VISU::Scaling VISU::PointMap3d_i::GetScaling()
957 return VISU::Scaling(GetSpecificPL()->GetScaling());
960 //------------------- Check Table on Positive Values ------------
961 bool VISU::PointMap3d_i::IsPositiveTable()
963 SALOMEDS::GenericAttribute_var anAttr;
964 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
965 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
967 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
968 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
969 double aVal = aTableOfReal->GetValue(j, i);
977 //------------------- Plot3dBase Methods ------------------------
979 void VISU::PointMap3d_i::SetScaleFactor (CORBA::Double theScaleFactor)
981 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType>
982 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaleFactor, theScaleFactor));
985 CORBA::Double VISU::PointMap3d_i::GetScaleFactor ()
987 return myTablePL->GetScaleFactor();
990 void VISU::PointMap3d_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
992 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, bool>
993 (GetSpecificPL(), &VISU_DeformedGridPL::SetContourPrs, theIsContourPrs));
996 CORBA::Boolean VISU::PointMap3d_i::GetIsContourPrs()
998 return myTablePL->GetIsContourPrs();
1001 void VISU::PointMap3d_i::SetNbOfContours (CORBA::Long theNb)
1003 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
1004 (GetSpecificPL(), &VISU_DeformedGridPL::SetNumberOfContours, theNb));
1007 CORBA::Long VISU::PointMap3d_i::GetNbOfContours ()
1009 return myTablePL->GetNumberOfContours();
1012 //-------------------- Actor Factory Methods --------------------
1014 bool VISU::PointMap3d_i::GetActiveState ()
1016 return myIsActiveState;
1019 void VISU::PointMap3d_i::SetActiveState ( bool theState )
1021 myIsActiveState = theState;
1024 void VISU::PointMap3d_i::RemoveActor (VISU_ActorBase* theActor)
1026 myActorCollection->RemoveItem(theActor);
1029 void VISU::PointMap3d_i::RemoveActors ()
1031 ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
1032 myActorCollection->RemoveAllItems();
1036 //-----------------------Text Properties & Label Properties------------------
1037 bool VISU::PointMap3d_i::IsBoldTitle()
1039 return myIsBoldTitle;
1042 //----------------------------------------------------------------------------
1043 void VISU::PointMap3d_i::SetBoldTitle(bool theIsBoldTitle)
1045 if(myIsBoldTitle == theIsBoldTitle)
1048 myIsBoldTitle = theIsBoldTitle;
1049 myParamsTime.Modified();
1052 //----------------------------------------------------------------------------
1053 bool VISU::PointMap3d_i::IsItalicTitle()
1055 return myIsItalicTitle;
1058 //----------------------------------------------------------------------------
1059 void VISU::PointMap3d_i::SetItalicTitle(bool theIsItalicTitle)
1061 if(myIsItalicTitle == theIsItalicTitle)
1064 myIsItalicTitle = theIsItalicTitle;
1065 myParamsTime.Modified();
1068 //----------------------------------------------------------------------------
1069 bool VISU::PointMap3d_i::IsShadowTitle()
1071 return myIsShadowTitle;
1074 //----------------------------------------------------------------------------
1075 void VISU::PointMap3d_i::SetShadowTitle(bool theIsShadowTitle)
1077 if(myIsShadowTitle == theIsShadowTitle)
1080 myIsShadowTitle = theIsShadowTitle;
1081 myParamsTime.Modified();
1084 //----------------------------------------------------------------------------
1085 int VISU::PointMap3d_i::GetTitFontType()
1087 return myTitFontType;
1090 //----------------------------------------------------------------------------
1091 void VISU::PointMap3d_i::SetTitFontType(int theTitFontType)
1093 if(myTitFontType == theTitFontType)
1096 myTitFontType = theTitFontType;
1097 myParamsTime.Modified();
1100 //----------------------------------------------------------------------------
1101 void VISU::PointMap3d_i::GetTitleColor(vtkFloatingPointType& theR,
1102 vtkFloatingPointType& theG,
1103 vtkFloatingPointType& theB)
1105 theR = myTitleColor[0];
1106 theG = myTitleColor[1];
1107 theB = myTitleColor[2];
1110 //----------------------------------------------------------------------------
1111 void VISU::PointMap3d_i::SetTitleColor(vtkFloatingPointType theR,
1112 vtkFloatingPointType theG,
1113 vtkFloatingPointType theB)
1115 bool anIsSameValue = VISU::CheckIsSameValue(myTitleColor[0], theR);
1116 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[1], theG);
1117 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[2], theB);
1121 myTitleColor[0] = theR;
1122 myTitleColor[1] = theG;
1123 myTitleColor[2] = theB;
1124 myParamsTime.Modified();
1127 //----------------------------------------------------------------------------
1128 bool VISU::PointMap3d_i::IsBoldLabel()
1130 return myIsBoldLabel;
1133 //----------------------------------------------------------------------------
1134 void VISU::PointMap3d_i::SetBoldLabel(bool theIsBoldLabel)
1136 if(myIsBoldLabel == theIsBoldLabel)
1139 myIsBoldLabel = theIsBoldLabel;
1140 myParamsTime.Modified();
1143 //----------------------------------------------------------------------------
1144 bool VISU::PointMap3d_i::IsItalicLabel()
1146 return myIsItalicLabel;
1149 //----------------------------------------------------------------------------
1150 void VISU::PointMap3d_i::SetItalicLabel(bool theIsItalicLabel)
1152 if(myIsItalicLabel == theIsItalicLabel)
1155 myIsItalicLabel = theIsItalicLabel;
1156 myParamsTime.Modified();
1159 //----------------------------------------------------------------------------
1160 bool VISU::PointMap3d_i::IsShadowLabel()
1162 return myIsShadowLabel;
1165 //----------------------------------------------------------------------------
1166 void VISU::PointMap3d_i::SetShadowLabel(bool theIsShadowLabel)
1168 if(myIsShadowLabel == theIsShadowLabel)
1171 myIsShadowLabel = theIsShadowLabel;
1172 myParamsTime.Modified();
1175 //----------------------------------------------------------------------------
1176 int VISU::PointMap3d_i::GetLblFontType()
1178 return myLblFontType;
1181 //----------------------------------------------------------------------------
1182 void VISU::PointMap3d_i::SetLblFontType(int theLblFontType)
1184 if(myLblFontType == theLblFontType)
1187 myLblFontType = theLblFontType;
1188 myParamsTime.Modified();
1191 //----------------------------------------------------------------------------
1192 void VISU::PointMap3d_i::GetLabelColor(vtkFloatingPointType& theR,
1193 vtkFloatingPointType& theG,
1194 vtkFloatingPointType& theB)
1196 theR = myLabelColor[0];
1197 theG = myLabelColor[1];
1198 theB = myLabelColor[2];
1201 //----------------------------------------------------------------------------
1202 void VISU::PointMap3d_i::SetLabelColor(vtkFloatingPointType theR,
1203 vtkFloatingPointType theG,
1204 vtkFloatingPointType theB)
1206 bool anIsSameValue = VISU::CheckIsSameValue(myLabelColor[0], theR);
1207 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[1], theG);
1208 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[2], theB);
1212 myLabelColor[0] = theR;
1213 myLabelColor[1] = theG;
1214 myLabelColor[2] = theB;
1215 myParamsTime.Modified();
1218 //----------------------------------------------------------------------------
1219 CORBA::Long VISU::PointMap3d_i::GetTitleSize()
1224 //----------------------------------------------------------------------------
1225 CORBA::Long VISU::PointMap3d_i::GetLabelSize()
1230 //----------------------------------------------------------------------------
1231 CORBA::Long VISU::PointMap3d_i::GetBarWidth()
1236 //----------------------------------------------------------------------------
1237 CORBA::Long VISU::PointMap3d_i::GetBarHeight()
1242 //----------------------------------------------------------------------------
1244 VISU::PointMap3d_i::SetLabelsFormat(const char* theFormat)
1246 if( myLabelsFormat != theFormat ){
1247 myLabelsFormat = theFormat;
1248 myParamsTime.Modified();
1252 //----------------------------------------------------------------------------
1253 char* VISU::PointMap3d_i::GetLabelsFormat()
1255 return CORBA::string_dup(myLabelsFormat.c_str());
1258 //----------------------------------------------------------------------------
1259 void VISU::PointMap3d_i::SetUnitsVisible(CORBA::Boolean isVisible)
1261 if( myIsUnits != isVisible ){
1262 myIsUnits = isVisible;
1263 myParamsTime.Modified();
1267 //----------------------------------------------------------------------------
1268 CORBA::Boolean VISU::PointMap3d_i::IsUnitsVisible()
1273 //----------------------------------------------------------------------------
1274 void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleSize,
1275 CORBA::Long theLabelSize,
1276 CORBA::Long theBarWidth, CORBA::Long theBarHeight)
1278 bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
1279 anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
1280 anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
1281 anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
1285 myTitleSize = theTitleSize;
1286 myLabelSize = theLabelSize;
1287 myBarWidth = theBarWidth;
1288 myBarHeight = theBarHeight;
1289 myParamsTime.Modified();