1 // Copyright (C) 2007-2012 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 anActor->highlight(anActor->isHighlighted()); // like in VISU::Prs3d_i::UpdateActor()
435 theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
442 if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActors - this = "<<this);
443 ProcessVoidEvent(new TVoidMemFunEvent<VISU_PipeLine>
444 (GetSpecificPL(), &VISU_PipeLine::Update));
446 ProcessVoidEvent(new VISU::TInvokeSignalEvent(myUpdateActorsSignal));
449 //----------------------------------------------------------------------------
454 if(GetMTime() < myUpdateTime.GetMTime())
457 if(MYDEBUG) MESSAGE("PointMap3d_i::Update - this = "<<this);
460 ProcessVoidEvent(new TVoidMemFunEvent<VISU_PipeLine>
461 (GetSpecificPL(), &VISU_PipeLine::Update));
462 myUpdateTime.Modified();
463 }catch(std::exception&){
466 throw std::runtime_error("PointMap3d_i::Update >> unexpected exception was caught!!!");
470 //----------------------------------------------------------------------------
475 unsigned long int aTime = myParamsTime.GetMTime();
476 if( GetSpecificPL() )
477 aTime = std::max(aTime, GetSpecificPL()->GetMTime());
482 Builds presentation of table
484 VISU::Storable* VISU::PointMap3d_i::Build( int theRestoring )
487 // look for reference SObject with table attribute
488 SALOMEDS::SObject_var SO = mySObj;
490 if ( !SO->_is_nil() ) {
491 CutLinesBase_i* pCutLines = NULL;
492 CORBA::Object_var anObj = SObjectToObject(SO);
493 if(!CORBA::is_nil(anObj)){
494 VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
495 if(!aCutLines->_is_nil())
496 pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
498 SALOMEDS::Study_var aStudy = GetStudyDocument();
499 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
500 SALOMEDS::GenericAttribute_var anAttr;
501 // look for component
502 if ( !theRestoring ) {
503 SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
504 // create SObject and set attributes
507 aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment());
509 aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment());
510 SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
511 if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
512 SALOMEDS::AttributeString_var aCommentAttr =
513 SALOMEDS::AttributeString::_narrow(anAttr);
514 CORBA::String_var aValue = aCommentAttr->Value();
515 Storable::TRestoringMap aMap;
516 Storable::StringToMap(aValue.in(),aMap);
518 QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
520 if(aMethodName == "ImportTables"){
521 aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment());
527 string anEntry = CreateAttributes( GetStudyDocument(),
528 SO->GetID(),//SComponent->GetID(),
533 aComment.toLatin1().constData(),
535 // create SObject referenced to real table object
536 mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
538 bool isCutSegment = dynamic_cast<CutSegment_i*>(pCutLines);
539 pCutLines->BuildTableOfReal(mySObj, isCutSegment);
541 // mpv (PAL5357): reference attributes are unnecessary now
542 //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
543 //Builder->Addreference( refSO, SO );
551 Restores table object from stream
553 VISU::Storable* VISU::PointMap3d_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO)
555 VISU::Table_i::Restore( theMap, SO);
556 if(MYDEBUG) MESSAGE(GetComment());
557 SetName(VISU::Storable::FindValue(theMap,"myName").toLatin1().constData(), false);
558 myTitle = VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData();
559 myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() );
560 mySObj = SALOMEDS::SObject::_duplicate(SO);
563 myTablePL = VISU_DeformedGridPL::New();
564 myTablePL->SetPolyDataIDMapper(GetTableIDMapper());
567 //Restore Other Values
569 float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
570 float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
571 SetRange(aMin, aMax);
573 UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt());
575 SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
576 SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt());
577 SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g").toLatin1().constData());
578 SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myBarOrientation").toInt());
580 SetTitle(VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData());
581 myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
582 myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
583 myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
584 myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
585 myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
586 myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt();
587 myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt();
588 myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
589 myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
591 myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
592 myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
593 myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
594 myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
595 myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
596 myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
597 myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
599 myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
600 myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
601 myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
602 myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
603 myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
604 myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
605 myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
607 bool isFound = false;
610 x = VISU::Storable::FindValue(theMap,"myOffset[0]",&isFound);
611 y = VISU::Storable::FindValue(theMap,"myOffset[1]",&isFound);
612 z = VISU::Storable::FindValue(theMap,"myOffset[2]",&isFound);
614 myOffset[0] = x.toFloat();
615 myOffset[1] = y.toFloat();
616 myOffset[2] = z.toFloat();
619 myParamsTime.Modified();
620 return Build( true );
623 Flushes table data into stream
625 void VISU::PointMap3d_i::ToStream( std::ostringstream& theStr )
627 Storable::DataToStream( theStr, "myName", GetName().c_str() );
628 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
629 Storable::DataToStream( theStr, "myOrientation", myOrientation );
631 Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
632 Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
633 Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
635 Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
636 Storable::DataToStream( theStr, "myBarOrientation", myBarOrientation );
638 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
639 Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
640 Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
641 Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
642 Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
643 Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
644 Storable::DataToStream( theStr, "myWidth", myWidth );
645 Storable::DataToStream( theStr, "myHeight", myHeight );
646 Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
647 Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
648 Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
649 Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
651 Storable::DataToStream( theStr, "myTitFontType", myTitFontType );
652 Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle );
653 Storable::DataToStream( theStr, "myIsItalicTitle", myIsItalicTitle );
654 Storable::DataToStream( theStr, "myIsShadowTitle", myIsShadowTitle );
655 Storable::DataToStream( theStr, "myTitleColor[0]", myTitleColor[0] );
656 Storable::DataToStream( theStr, "myTitleColor[1]", myTitleColor[1] );
657 Storable::DataToStream( theStr, "myTitleColor[2]", myTitleColor[2] );
659 Storable::DataToStream( theStr, "myLblFontType", myLblFontType );
660 Storable::DataToStream( theStr, "myIsBoldLabel", myIsBoldLabel );
661 Storable::DataToStream( theStr, "myIsItalicLabel", myIsItalicLabel );
662 Storable::DataToStream( theStr, "myIsShadowLabel", myIsShadowLabel );
663 Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] );
664 Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] );
665 Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] );
667 Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
668 Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
669 Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
672 Called from engine to restore table from the file
674 VISU::Storable* VISU::PointMap3d_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
675 const Storable::TRestoringMap& theMap,
676 const std::string& thePrefix,
677 CORBA::Boolean theIsMultiFile)
679 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
680 VISU::PointMap3d_i* pResent = new VISU::PointMap3d_i( aStudy, "" );
681 return pResent->Restore( theMap, theSObject);
684 Gets title for the original table object
686 QString VISU::PointMap3d_i::GetTableTitle()
688 SALOMEDS::SObject_var SO = mySObj;
689 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
690 SALOMEDS::GenericAttribute_var anAttr;
691 SALOMEDS::AttributeTableOfInteger_var anInt;
692 SALOMEDS::AttributeTableOfReal_var aReal;
693 if ( !SO->_is_nil() ) {
694 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
695 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
696 CORBA::String_var aString = anInt->GetTitle();
699 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
700 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
701 CORBA::String_var aString = aReal->GetTitle();
708 //---------------------------------------------------------------
709 void VISU::PointMap3d_i::RemoveFromStudy()
711 struct TRemoveFromStudy: public SALOME_Event
713 VISU::PointMap3d_i* myRemovable;
714 TRemoveFromStudy(VISU::PointMap3d_i* theRemovable):
715 myRemovable(theRemovable)
722 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
726 // Remove the table with all curves
727 ProcessVoidEvent(new TRemoveFromStudy(this));
730 //----------------------------------------------------------------
731 void VISU::PointMap3d_i::SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz)
733 VISU::TSetModified aModified(this);
737 myParamsTime.Modified();
740 void VISU::PointMap3d_i::GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz)
747 void VISU::PointMap3d_i::SetMarkerStd(VISU::MarkerType, VISU::MarkerScale)
751 void VISU::PointMap3d_i::SetMarkerTexture(CORBA::Long)
755 VISU::MarkerType VISU::PointMap3d_i::GetMarkerType()
757 return VISU::MT_NONE;
760 VISU::MarkerScale VISU::PointMap3d_i::GetMarkerScale()
762 return VISU::MS_NONE;
765 CORBA::Long VISU::PointMap3d_i::GetMarkerTexture()
770 CORBA::Float VISU::PointMap3d_i::GetMemorySize()
772 CORBA::Float aSize = GetSpecificPL()->GetMemorySize();
774 int anEnd = myActorCollection->GetNumberOfItems();
775 for(int anId = 0; anId < anEnd; anId++)
776 if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
777 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
778 aSize += anActor->GetMemorySize();
779 //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
782 // Convert to mega bytes
783 return aSize / (1024.0 * 1024.0);
786 //------------------ ColoredPrs3dBase Methods --------------------
787 CORBA::Double VISU::PointMap3d_i::GetMin()
789 return myTablePL->GetScalarRange()[0];
792 CORBA::Double VISU::PointMap3d_i::GetMinTableValue()
794 SALOMEDS::GenericAttribute_var anAttr;
795 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
796 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
797 double aMin = aTableOfReal->GetValue(1, 1);
799 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
800 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
801 double aVal = aTableOfReal->GetValue(j, i);
809 CORBA::Double VISU::PointMap3d_i::GetMaxTableValue()
811 SALOMEDS::GenericAttribute_var anAttr;
812 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
813 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
814 double aMax = aTableOfReal->GetValue(1, 1);
816 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
817 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
818 double aVal = aTableOfReal->GetValue(j, i);
826 CORBA::Double VISU::PointMap3d_i::GetMax()
828 return myTablePL->GetScalarRange()[1];
831 void VISU::PointMap3d_i::SetRange(CORBA::Double theMin, CORBA::Double theMax)
833 vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
834 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType*>
835 (GetSpecificPL(), &VISU_DeformedGridPL::SetScalarRange, aScalarRange));
840 CORBA::Double VISU::PointMap3d_i::GetSourceMin()
842 vtkFloatingPointType aRange[2];
843 GetSpecificPL()->GetSourceRange(aRange);
847 CORBA::Double VISU::PointMap3d_i::GetSourceMax()
849 vtkFloatingPointType aRange[2];
850 GetSpecificPL()->GetSourceRange(aRange);
854 void VISU::PointMap3d_i::SetSourceRange()
856 GetSpecificPL()->SetSourceRange();
857 ProcessVoidEvent(new TVoidMemFunEvent<VISU_DeformedGridPL>
858 (GetSpecificPL(), &VISU_DeformedGridPL::SetSourceRange));
860 UseFixedRange(false);
863 CORBA::Boolean VISU::PointMap3d_i::IsRangeFixed()
865 return myIsFixedRange;
868 void VISU::PointMap3d_i::UseFixedRange(bool theRange)
870 if(myIsFixedRange == theRange)
873 myIsFixedRange = theRange;
876 void VISU::PointMap3d_i::SetPosition(CORBA::Double theX, CORBA::Double theY)
878 bool anIsSameValue = VISU::CheckIsSameValue(myPosition[0], theX);
879 anIsSameValue &= VISU::CheckIsSameValue(myPosition[1], theY);
883 myPosition[0] = theX;
884 myPosition[1] = theY;
885 myParamsTime.Modified();
888 CORBA::Double VISU::PointMap3d_i::GetPosX()
890 return myPosition[0];
893 CORBA::Double VISU::PointMap3d_i::GetPosY()
895 return myPosition[1];
898 void VISU::PointMap3d_i::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
900 bool anIsSameValue = VISU::CheckIsSameValue(myWidth, theWidth);
901 anIsSameValue &= VISU::CheckIsSameValue(myHeight, theHeight);
906 myHeight = theHeight;
907 myParamsTime.Modified();
910 CORBA::Double VISU::PointMap3d_i::GetHeight()
915 CORBA::Double VISU::PointMap3d_i::GetWidth()
920 void VISU::PointMap3d_i::SetNbColors(CORBA::Long theNbColors)
922 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
923 (GetSpecificPL(), &VISU_DeformedGridPL::SetNbColors, theNbColors));
926 CORBA::Long VISU::PointMap3d_i::GetNbColors()
928 return GetSpecificPL()->GetNbColors();
931 void VISU::PointMap3d_i::SetLabels(CORBA::Long theNbLabels)
933 if(myNumberOfLabels == theNbLabels)
936 myNumberOfLabels = theNbLabels;
939 CORBA::Long VISU::PointMap3d_i::GetLabels()
941 return myNumberOfLabels;
944 void VISU::PointMap3d_i::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theBarOrientation)
946 if(myBarOrientation == theBarOrientation)
949 if ( ( theBarOrientation == VISU::ColoredPrs3dBase::VERTICAL && myHeight < myWidth ) ||
950 ( theBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL && myHeight > myWidth ) ) {
951 vtkFloatingPointType tmp = myHeight;
956 myBarOrientation = theBarOrientation;
957 myParamsTime.Modified();
960 VISU::ColoredPrs3dBase::Orientation VISU::PointMap3d_i::GetBarOrientation()
962 return myBarOrientation;
965 //------------------- ScaledPrs3d Methods -----------------------
967 void VISU::PointMap3d_i::SetScaling(VISU::Scaling theScaling)
969 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
970 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaling, theScaling));
973 VISU::Scaling VISU::PointMap3d_i::GetScaling()
975 return VISU::Scaling(GetSpecificPL()->GetScaling());
978 //------------------- Check Table on Positive Values ------------
979 bool VISU::PointMap3d_i::IsPositiveTable()
981 SALOMEDS::GenericAttribute_var anAttr;
982 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
983 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
985 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
986 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
987 double aVal = aTableOfReal->GetValue(j, i);
995 //------------------- Plot3dBase Methods ------------------------
997 void VISU::PointMap3d_i::SetScaleFactor (CORBA::Double theScaleFactor)
999 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType>
1000 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaleFactor, theScaleFactor));
1003 CORBA::Double VISU::PointMap3d_i::GetScaleFactor ()
1005 return myTablePL->GetScaleFactor();
1008 void VISU::PointMap3d_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
1010 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, bool>
1011 (GetSpecificPL(), &VISU_DeformedGridPL::SetContourPrs, theIsContourPrs));
1014 CORBA::Boolean VISU::PointMap3d_i::GetIsContourPrs()
1016 return myTablePL->GetIsContourPrs();
1019 void VISU::PointMap3d_i::SetNbOfContours (CORBA::Long theNb)
1021 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
1022 (GetSpecificPL(), &VISU_DeformedGridPL::SetNumberOfContours, theNb));
1025 CORBA::Long VISU::PointMap3d_i::GetNbOfContours ()
1027 return myTablePL->GetNumberOfContours();
1030 //-------------------- Actor Factory Methods --------------------
1032 bool VISU::PointMap3d_i::GetActiveState ()
1034 return myIsActiveState;
1037 void VISU::PointMap3d_i::SetActiveState ( bool theState )
1039 myIsActiveState = theState;
1042 void VISU::PointMap3d_i::RemoveActor (VISU_ActorBase* theActor)
1044 myActorCollection->RemoveItem(theActor);
1047 void VISU::PointMap3d_i::RemoveActors ()
1049 ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
1050 myActorCollection->RemoveAllItems();
1054 //-----------------------Text Properties & Label Properties------------------
1055 bool VISU::PointMap3d_i::IsBoldTitle()
1057 return myIsBoldTitle;
1060 //----------------------------------------------------------------------------
1061 void VISU::PointMap3d_i::SetBoldTitle(bool theIsBoldTitle)
1063 if(myIsBoldTitle == theIsBoldTitle)
1066 myIsBoldTitle = theIsBoldTitle;
1067 myParamsTime.Modified();
1070 //----------------------------------------------------------------------------
1071 bool VISU::PointMap3d_i::IsItalicTitle()
1073 return myIsItalicTitle;
1076 //----------------------------------------------------------------------------
1077 void VISU::PointMap3d_i::SetItalicTitle(bool theIsItalicTitle)
1079 if(myIsItalicTitle == theIsItalicTitle)
1082 myIsItalicTitle = theIsItalicTitle;
1083 myParamsTime.Modified();
1086 //----------------------------------------------------------------------------
1087 bool VISU::PointMap3d_i::IsShadowTitle()
1089 return myIsShadowTitle;
1092 //----------------------------------------------------------------------------
1093 void VISU::PointMap3d_i::SetShadowTitle(bool theIsShadowTitle)
1095 if(myIsShadowTitle == theIsShadowTitle)
1098 myIsShadowTitle = theIsShadowTitle;
1099 myParamsTime.Modified();
1102 //----------------------------------------------------------------------------
1103 int VISU::PointMap3d_i::GetTitFontType()
1105 return myTitFontType;
1108 //----------------------------------------------------------------------------
1109 void VISU::PointMap3d_i::SetTitFontType(int theTitFontType)
1111 if(myTitFontType == theTitFontType)
1114 myTitFontType = theTitFontType;
1115 myParamsTime.Modified();
1118 //----------------------------------------------------------------------------
1119 void VISU::PointMap3d_i::GetTitleColor(vtkFloatingPointType& theR,
1120 vtkFloatingPointType& theG,
1121 vtkFloatingPointType& theB)
1123 theR = myTitleColor[0];
1124 theG = myTitleColor[1];
1125 theB = myTitleColor[2];
1128 //----------------------------------------------------------------------------
1129 void VISU::PointMap3d_i::SetTitleColor(vtkFloatingPointType theR,
1130 vtkFloatingPointType theG,
1131 vtkFloatingPointType theB)
1133 bool anIsSameValue = VISU::CheckIsSameValue(myTitleColor[0], theR);
1134 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[1], theG);
1135 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[2], theB);
1139 myTitleColor[0] = theR;
1140 myTitleColor[1] = theG;
1141 myTitleColor[2] = theB;
1142 myParamsTime.Modified();
1145 //----------------------------------------------------------------------------
1146 bool VISU::PointMap3d_i::IsBoldLabel()
1148 return myIsBoldLabel;
1151 //----------------------------------------------------------------------------
1152 void VISU::PointMap3d_i::SetBoldLabel(bool theIsBoldLabel)
1154 if(myIsBoldLabel == theIsBoldLabel)
1157 myIsBoldLabel = theIsBoldLabel;
1158 myParamsTime.Modified();
1161 //----------------------------------------------------------------------------
1162 bool VISU::PointMap3d_i::IsItalicLabel()
1164 return myIsItalicLabel;
1167 //----------------------------------------------------------------------------
1168 void VISU::PointMap3d_i::SetItalicLabel(bool theIsItalicLabel)
1170 if(myIsItalicLabel == theIsItalicLabel)
1173 myIsItalicLabel = theIsItalicLabel;
1174 myParamsTime.Modified();
1177 //----------------------------------------------------------------------------
1178 bool VISU::PointMap3d_i::IsShadowLabel()
1180 return myIsShadowLabel;
1183 //----------------------------------------------------------------------------
1184 void VISU::PointMap3d_i::SetShadowLabel(bool theIsShadowLabel)
1186 if(myIsShadowLabel == theIsShadowLabel)
1189 myIsShadowLabel = theIsShadowLabel;
1190 myParamsTime.Modified();
1193 //----------------------------------------------------------------------------
1194 int VISU::PointMap3d_i::GetLblFontType()
1196 return myLblFontType;
1199 //----------------------------------------------------------------------------
1200 void VISU::PointMap3d_i::SetLblFontType(int theLblFontType)
1202 if(myLblFontType == theLblFontType)
1205 myLblFontType = theLblFontType;
1206 myParamsTime.Modified();
1209 //----------------------------------------------------------------------------
1210 void VISU::PointMap3d_i::GetLabelColor(vtkFloatingPointType& theR,
1211 vtkFloatingPointType& theG,
1212 vtkFloatingPointType& theB)
1214 theR = myLabelColor[0];
1215 theG = myLabelColor[1];
1216 theB = myLabelColor[2];
1219 //----------------------------------------------------------------------------
1220 void VISU::PointMap3d_i::SetLabelColor(vtkFloatingPointType theR,
1221 vtkFloatingPointType theG,
1222 vtkFloatingPointType theB)
1224 bool anIsSameValue = VISU::CheckIsSameValue(myLabelColor[0], theR);
1225 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[1], theG);
1226 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[2], theB);
1230 myLabelColor[0] = theR;
1231 myLabelColor[1] = theG;
1232 myLabelColor[2] = theB;
1233 myParamsTime.Modified();
1236 //----------------------------------------------------------------------------
1237 CORBA::Long VISU::PointMap3d_i::GetTitleSize()
1242 //----------------------------------------------------------------------------
1243 CORBA::Long VISU::PointMap3d_i::GetLabelSize()
1248 //----------------------------------------------------------------------------
1249 CORBA::Long VISU::PointMap3d_i::GetBarWidth()
1254 //----------------------------------------------------------------------------
1255 CORBA::Long VISU::PointMap3d_i::GetBarHeight()
1260 //----------------------------------------------------------------------------
1262 VISU::PointMap3d_i::SetLabelsFormat(const char* theFormat)
1264 if( myLabelsFormat != theFormat ){
1265 myLabelsFormat = theFormat;
1266 myParamsTime.Modified();
1270 //----------------------------------------------------------------------------
1271 char* VISU::PointMap3d_i::GetLabelsFormat()
1273 return CORBA::string_dup(myLabelsFormat.c_str());
1276 //----------------------------------------------------------------------------
1277 void VISU::PointMap3d_i::SetUnitsVisible(CORBA::Boolean isVisible)
1279 if( myIsUnits != isVisible ){
1280 myIsUnits = isVisible;
1281 myParamsTime.Modified();
1285 //----------------------------------------------------------------------------
1286 CORBA::Boolean VISU::PointMap3d_i::IsUnitsVisible()
1291 //----------------------------------------------------------------------------
1292 void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleSize,
1293 CORBA::Long theLabelSize,
1294 CORBA::Long theBarWidth, CORBA::Long theBarHeight)
1296 bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
1297 anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
1298 anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
1299 anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
1303 myTitleSize = theTitleSize;
1304 myLabelSize = theLabelSize;
1305 myBarWidth = theBarWidth;
1306 myBarHeight = theBarHeight;
1307 myParamsTime.Modified();