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_PointMap3d_i.cc
24 // Author : Dmitry Matveitchev
27 #include "VISU_PointMap3d_i.hh"
29 #include "VISU_CutLinesBase_i.hh"
30 #include "VISU_Result_i.hh"
31 #include "VISU_ViewManager_i.hh"
32 #include "VISU_ScalarBarActor.hxx"
33 #include "SUIT_ResourceMgr.h"
35 #include "SALOME_Event.h"
36 #include "VISU_Prs3dUtils.hh"
37 #include "SPlot2d_Curve.h"
38 #include "VISU_PipeLineUtils.hxx"
40 #include "VISU_TableReader.hxx"
41 #include "VISU_ConvertorUtils.hxx"
42 #include "VISU_DeformedGridPL.hxx"
44 #include "SALOME_InteractiveObject.hxx"
45 #include "VISU_Gen_i.hh"
47 #include <vtkTextProperty.h>
48 #include <vtkActorCollection.h>
50 #include <boost/bind.hpp>
53 static int MYDEBUG = 0;
55 static int MYDEBUG = 0;
60 //----------------------------------------------------------------
62 //----------------------------------------------------------------
63 int VISU::PointMap3d_i::myNbPresent = 0;
64 const string VISU::PointMap3d_i::myComment = "POINTMAP3D";
68 QString VISU::PointMap3d_i::GenerateName()
70 return VISU::GenerateName( "Table3D - ", ++myNbPresent );
75 const char* VISU::PointMap3d_i::GetComment() const
77 return myComment.c_str();
82 VISU::PointMap3d_i::PointMap3d_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry )
83 : Table_i(theStudy, theObjectEntry),
84 myActorCollection(vtkActorCollection::New()),
87 if(MYDEBUG) MESSAGE("PointMap3d_i::PointMap3d_i - this = "<<this);
88 SetStudyDocument(theStudy);
89 mySObj = theStudy->FindObjectID(theObjectEntry);
90 myOffset[0] = myOffset[1] = myOffset[2] = 0;
91 myActorCollection->Delete();
96 VISU::PointMap3d_i::~PointMap3d_i()
98 if(MYDEBUG) MESSAGE("PointMap3d_i::~PointMap3d_i - this = "<<this);
101 //----------------------------------------------------------------------------
104 struct TInvokeSignalEvent: public SALOME_Event
106 typedef boost::signal0<void> TSignal;
107 const TSignal& mySignal;
109 TInvokeSignalEvent(const TSignal& theSignal):
122 //----------------------------------------------------------------------------
125 ::SetTitle( const char* theTitle )
127 SetName( theTitle, true );
130 //----------------------------------------------------------------------------
135 return CORBA::string_dup( GetName().c_str() );
138 //----------------------------------------------------------------------------
139 SALOMEDS::SObject_var
146 //----------------------------------------------------------------------------
151 CORBA::String_var anEntry = mySObj->GetID();
155 //----------------------------------------------------------------------------
156 Handle(SALOME_InteractiveObject)
161 myIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str());
166 //----------------------------------------------------------------------------
168 Creates table3d object
170 VISU::Storable* VISU::PointMap3d_i::Create()
173 SetName(GetTableTitle().toLatin1().constData(), false);
175 if ( GetName() == "" ) {
176 if ( !mySObj->_is_nil() ) {
177 CutLinesBase_i* pCutLines = NULL;
178 CORBA::Object_var anObj = SObjectToObject(mySObj);
179 if(!CORBA::is_nil(anObj)){
180 VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
181 if(!aCutLines->_is_nil())
182 pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
185 if (mySObj->GetName()) SetName(mySObj->GetName(), false);
189 if ( GetName() == "" )
190 SetName(GenerateName().toLatin1().constData(), false);
193 myTablePL = VISU_DeformedGridPL::New();
194 myTablePL->SetPolyDataIDMapper(GetTableIDMapper());
197 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
199 bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true );
200 SetUnitsVisible(isUnits);
204 if( aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false) )
205 SetScaling(VISU::LOGARITHMIC);
207 SetScaling(VISU::LINEAR);
209 int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 );
210 SetNbColors(aNumberOfColors);
212 int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
213 UseFixedRange(aRangeType == 1);
215 float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0);
216 float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0);
217 SetRange(aMin, aMax);
220 int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 );
221 SetLabelsFormat( VISU::ToFormat( lp ).c_str() );
224 int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
225 if(anOrientation == 1)
226 SetBarOrientation(VISU::ColoredPrs3dBase::HORIZONTAL);
228 SetBarOrientation(VISU::ColoredPrs3dBase::VERTICAL);
231 QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" );
233 vtkFloatingPointType aXorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.2;
234 aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin);
235 myPosition[0] = aXorigin;
237 vtkFloatingPointType aYorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.012;
238 aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin);
239 myPosition[1] = aYorigin;
242 myWidth = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.1 : 0.6;
243 myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth);
245 myHeight = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12;
246 myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
248 myTitleSize = aResourceMgr->doubleValue("VISU", propertyName + "title_size", 0);
249 myLabelSize = aResourceMgr->doubleValue("VISU", propertyName + "label_size", 0);
250 myBarWidth = aResourceMgr->doubleValue("VISU", propertyName + "bar_width", 0);
251 myBarHeight = aResourceMgr->doubleValue("VISU", propertyName + "bar_height", 0);
254 myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 );
256 // Fonts properties definition
257 myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true;
258 myTitFontType = VTK_ARIAL;
260 if(aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" )){
261 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
262 if ( f.family() == "Arial" )
263 myTitFontType = VTK_ARIAL;
264 else if ( f.family() == "Courier" )
265 myTitFontType = VTK_COURIER;
266 else if ( f.family() == "Times" )
267 myTitFontType = VTK_TIMES;
269 myIsBoldTitle = f.bold();
270 myIsItalicTitle = f.italic();
271 myIsShadowTitle = f.overline();
274 QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
276 myTitleColor[0] = aTextColor.red() / 255;
277 myTitleColor[1] = aTextColor.green() / 255;
278 myTitleColor[2] = aTextColor.blue() / 255;
280 myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true;
281 myLblFontType = VTK_ARIAL;
283 if( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" )){
284 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
285 if ( f.family() == "Arial" )
286 myLblFontType = VTK_ARIAL;
287 else if ( f.family() == "Courier" )
288 myLblFontType = VTK_COURIER;
289 else if ( f.family() == "Times" )
290 myLblFontType = VTK_TIMES;
292 myIsBoldLabel = f.bold();
293 myIsItalicLabel = f.italic();
294 myIsShadowLabel = f.overline();
297 QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
299 myLabelColor[0] = aLabelColor.red() / 255;
300 myLabelColor[1] = aLabelColor.green() / 255;
301 myLabelColor[2] = aLabelColor.blue() / 255;
303 // scalar bar default position
304 bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
307 aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
309 if(myBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL){
310 myPosition[1] += myHeight*(aPlace-1);
312 myPosition[0] += myWidth*(aPlace-1);
315 return Build( false );
326 //Initialisate table mapper
327 SALOMEDS::GenericAttribute_var anAttr;
328 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
329 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
331 PTableIDMapper aTableIDMapper( new TTableIDMapper() );
332 TTable2D& aTable2D = *aTableIDMapper;
334 aTable2D.myTitle = aTableOfReal->GetTitle();
336 SALOMEDS::StringSeq_var aColStrList = aTableOfReal->GetColumnTitles();
337 SALOMEDS::StringSeq_var aRowStrList = aTableOfReal->GetRowTitles();
339 for ( int i = 0; i < aRowStrList->length(); i++ ) {
340 aTable2D.myColumnTitles.push_back( aRowStrList[ i ].in() );
343 int aCols = aTableOfReal->GetNbColumns();
344 int aRows = aTableOfReal->GetNbRows();
346 for (int i=1; i<=aCols; i++) {
348 aRow.myTitle = aColStrList[ i-1 ].in();
349 for (int j=1; j<=aRows; j++) {
350 double aVal = aTableOfReal->GetValue(j, i);
351 QString aValStr = QString::number(aVal);
352 aRow.myValues.push_back( aValStr.toLatin1().constData() );
354 if( aRow.myValues.size() > 0 )
355 aTable2D.myRows.push_back( aRow );
358 return aTableIDMapper;
364 VISU_PointMap3dActor* VISU::PointMap3d_i::CreateActor()
366 VISU_PointMap3dActor* anActor = VISU_PointMap3dActor::New();
367 anActor->SetPipeLine(myTablePL);
368 anActor->SetFactory(this);
370 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
371 int aDispMode = aResourceMgr->integerValue("VISU", "point_map_represent", 2);
372 bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_map_shrink", false);
373 anActor->SetRepresentation(aDispMode);
374 if (toShrink) anActor->SetShrink();
376 Handle (SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str());
377 anActor->setIO(anIO);
379 myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,anActor));
380 // myRemoveActorsFromRendererSignal.connect(boost::bind(&VISU_Actor::RemoveFromRender,anActor));
382 myActorCollection->AddItem(anActor);
384 UpdateActor( anActor );
392 void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor)
394 if(VISU_PointMap3dActor* anActor = dynamic_cast<VISU_PointMap3dActor*>(theActor)){
396 VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
397 aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable());
398 aScalarBar->SetTitle(GetTitle());
399 aScalarBar->SetOrientation(GetBarOrientation());
400 aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
401 aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY());
402 aScalarBar->SetWidth(GetWidth());
403 aScalarBar->SetHeight(GetHeight());
404 aScalarBar->SetNumberOfLabels(GetLabels());
405 aScalarBar->SetRatios(myTitleSize, myLabelSize,
406 myBarWidth, myBarHeight);
407 aScalarBar->SetNumberOfLabels(GetLabels());
408 aScalarBar->SetLabelFormat(GetLabelsFormat());
410 vtkFloatingPointType anRGB[3];
412 vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
413 aTitleProp->SetFontFamily(GetTitFontType());
415 GetTitleColor(anRGB[0],anRGB[1],anRGB[2]);
416 aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
418 IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
419 IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
420 IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
422 vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
423 aLabelProp->SetFontFamily(GetLblFontType());
425 GetLabelColor(anRGB[0],anRGB[1],anRGB[2]);
426 aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
428 IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
429 IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
430 IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
432 aScalarBar->Modified();
434 theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
441 if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActors - this = "<<this);
442 ProcessVoidEvent(new TVoidMemFunEvent<VISU_PipeLine>
443 (GetSpecificPL(), &VISU_PipeLine::Update));
445 ProcessVoidEvent(new VISU::TInvokeSignalEvent(myUpdateActorsSignal));
448 //----------------------------------------------------------------------------
453 if(GetMTime() < myUpdateTime.GetMTime())
456 if(MYDEBUG) MESSAGE("PointMap3d_i::Update - this = "<<this);
459 ProcessVoidEvent(new TVoidMemFunEvent<VISU_PipeLine>
460 (GetSpecificPL(), &VISU_PipeLine::Update));
461 myUpdateTime.Modified();
462 }catch(std::exception&){
465 throw std::runtime_error("PointMap3d_i::Update >> unexpected exception was caught!!!");
469 //----------------------------------------------------------------------------
474 unsigned long int aTime = myParamsTime.GetMTime();
475 if( GetSpecificPL() )
476 aTime = std::max(aTime, GetSpecificPL()->GetMTime());
481 Builds presentation of table
483 VISU::Storable* VISU::PointMap3d_i::Build( int theRestoring )
486 // look for reference SObject with table attribute
487 SALOMEDS::SObject_var SO = mySObj;
489 if ( !SO->_is_nil() ) {
490 CutLinesBase_i* pCutLines = NULL;
491 CORBA::Object_var anObj = SObjectToObject(SO);
492 if(!CORBA::is_nil(anObj)){
493 VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
494 if(!aCutLines->_is_nil())
495 pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
497 SALOMEDS::Study_var aStudy = GetStudyDocument();
498 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
499 SALOMEDS::GenericAttribute_var anAttr;
500 // look for component
501 if ( !theRestoring ) {
502 SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
503 // create SObject and set attributes
506 aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment());
508 aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment());
509 SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
510 if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
511 SALOMEDS::AttributeString_var aCommentAttr =
512 SALOMEDS::AttributeString::_narrow(anAttr);
513 CORBA::String_var aValue = aCommentAttr->Value();
514 Storable::TRestoringMap aMap;
515 Storable::StringToMap(aValue.in(),aMap);
517 QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
519 if(aMethodName == "ImportTables"){
520 aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment());
526 string anEntry = CreateAttributes( GetStudyDocument(),
527 SO->GetID(),//SComponent->GetID(),
532 aComment.toLatin1().constData(),
534 // create SObject referenced to real table object
535 mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
537 pCutLines->BuildTableOfReal(mySObj);
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 if(MYDEBUG) MESSAGE(GetComment());
554 SetName(VISU::Storable::FindValue(theMap,"myName").toLatin1().constData(), false);
555 myTitle = VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData();
556 myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() );
557 mySObj = SALOMEDS::SObject::_duplicate(SO);
560 myTablePL = VISU_DeformedGridPL::New();
561 myTablePL->SetPolyDataIDMapper(GetTableIDMapper());
564 //Restore Other Values
566 float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
567 float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
568 SetRange(aMin, aMax);
570 UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt());
572 SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
573 SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt());
574 SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g").toLatin1().constData());
575 SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myBarOrientation").toInt());
577 SetTitle(VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData());
578 myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
579 myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
580 myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
581 myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
582 myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
583 myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt();
584 myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt();
585 myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
586 myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
588 myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
589 myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
590 myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
591 myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
592 myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
593 myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
594 myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
596 myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
597 myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
598 myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
599 myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
600 myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
601 myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
602 myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
604 myParamsTime.Modified();
605 return Build( true );
608 Flushes table data into stream
610 void VISU::PointMap3d_i::ToStream( std::ostringstream& theStr )
612 Storable::DataToStream( theStr, "myName", GetName().c_str() );
613 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
614 Storable::DataToStream( theStr, "myOrientation", myOrientation );
616 Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
617 Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
618 Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
620 Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
621 Storable::DataToStream( theStr, "myBarOrientation", myBarOrientation );
623 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
624 Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
625 Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
626 Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
627 Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
628 Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
629 Storable::DataToStream( theStr, "myWidth", myWidth );
630 Storable::DataToStream( theStr, "myHeight", myHeight );
631 Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
632 Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
633 Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
634 Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
636 Storable::DataToStream( theStr, "myTitFontType", myTitFontType );
637 Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle );
638 Storable::DataToStream( theStr, "myIsItalicTitle", myIsItalicTitle );
639 Storable::DataToStream( theStr, "myIsShadowTitle", myIsShadowTitle );
640 Storable::DataToStream( theStr, "myTitleColor[0]", myTitleColor[0] );
641 Storable::DataToStream( theStr, "myTitleColor[1]", myTitleColor[1] );
642 Storable::DataToStream( theStr, "myTitleColor[2]", myTitleColor[2] );
644 Storable::DataToStream( theStr, "myLblFontType", myLblFontType );
645 Storable::DataToStream( theStr, "myIsBoldLabel", myIsBoldLabel );
646 Storable::DataToStream( theStr, "myIsItalicLabel", myIsItalicLabel );
647 Storable::DataToStream( theStr, "myIsShadowLabel", myIsShadowLabel );
648 Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] );
649 Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] );
650 Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] );
653 Called from engine to restore table from the file
655 VISU::Storable* VISU::PointMap3d_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
656 const Storable::TRestoringMap& theMap,
657 const std::string& thePrefix,
658 CORBA::Boolean theIsMultiFile)
660 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
661 VISU::PointMap3d_i* pResent = new VISU::PointMap3d_i( aStudy, "" );
662 return pResent->Restore( theMap, theSObject);
665 Gets title for the original table object
667 QString VISU::PointMap3d_i::GetTableTitle()
669 SALOMEDS::SObject_var SO = mySObj;
670 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
671 SALOMEDS::GenericAttribute_var anAttr;
672 SALOMEDS::AttributeTableOfInteger_var anInt;
673 SALOMEDS::AttributeTableOfReal_var aReal;
674 if ( !SO->_is_nil() ) {
675 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
676 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
677 CORBA::String_var aString = anInt->GetTitle();
680 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
681 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
682 CORBA::String_var aString = aReal->GetTitle();
689 //---------------------------------------------------------------
690 void VISU::PointMap3d_i::RemoveFromStudy()
692 struct TRemoveFromStudy: public SALOME_Event
694 VISU::PointMap3d_i* myRemovable;
695 TRemoveFromStudy(VISU::PointMap3d_i* theRemovable):
696 myRemovable(theRemovable)
703 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
707 // Remove the table with all curves
708 ProcessVoidEvent(new TRemoveFromStudy(this));
711 //----------------------------------------------------------------
712 void VISU::PointMap3d_i::SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz)
717 myParamsTime.Modified();
720 void VISU::PointMap3d_i::GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz)
727 CORBA::Float VISU::PointMap3d_i::GetMemorySize()
729 CORBA::Float aSize = GetSpecificPL()->GetMemorySize();
731 int anEnd = myActorCollection->GetNumberOfItems();
732 for(int anId = 0; anId < anEnd; anId++)
733 if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
734 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
735 aSize += anActor->GetMemorySize();
736 //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
739 // Convert to mega bytes
740 return aSize / (1024.0 * 1024.0);
743 //------------------ ColoredPrs3dBase Methods --------------------
744 CORBA::Double VISU::PointMap3d_i::GetMin()
746 return myTablePL->GetScalarRange()[0];
749 CORBA::Double VISU::PointMap3d_i::GetMinTableValue()
751 SALOMEDS::GenericAttribute_var anAttr;
752 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
753 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
754 double aMin = aTableOfReal->GetValue(1, 1);
756 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
757 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
758 double aVal = aTableOfReal->GetValue(j, i);
766 CORBA::Double VISU::PointMap3d_i::GetMaxTableValue()
768 SALOMEDS::GenericAttribute_var anAttr;
769 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
770 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
771 double aMax = aTableOfReal->GetValue(1, 1);
773 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
774 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
775 double aVal = aTableOfReal->GetValue(j, i);
783 CORBA::Double VISU::PointMap3d_i::GetMax()
785 return myTablePL->GetScalarRange()[1];
788 void VISU::PointMap3d_i::SetRange(CORBA::Double theMin, CORBA::Double theMax)
790 vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
791 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType*>
792 (GetSpecificPL(), &VISU_DeformedGridPL::SetScalarRange, aScalarRange));
797 CORBA::Double VISU::PointMap3d_i::GetSourceMin()
799 vtkFloatingPointType aRange[2];
800 GetSpecificPL()->GetSourceRange(aRange);
804 CORBA::Double VISU::PointMap3d_i::GetSourceMax()
806 vtkFloatingPointType aRange[2];
807 GetSpecificPL()->GetSourceRange(aRange);
811 void VISU::PointMap3d_i::SetSourceRange()
813 GetSpecificPL()->SetSourceRange();
814 ProcessVoidEvent(new TVoidMemFunEvent<VISU_DeformedGridPL>
815 (GetSpecificPL(), &VISU_DeformedGridPL::SetSourceRange));
817 UseFixedRange(false);
820 CORBA::Boolean VISU::PointMap3d_i::IsRangeFixed()
822 return myIsFixedRange;
825 void VISU::PointMap3d_i::UseFixedRange(bool theRange)
827 if(myIsFixedRange == theRange)
830 myIsFixedRange = theRange;
833 void VISU::PointMap3d_i::SetPosition(CORBA::Double theX, CORBA::Double theY)
835 bool anIsSameValue = VISU::CheckIsSameValue(myPosition[0], theX);
836 anIsSameValue &= VISU::CheckIsSameValue(myPosition[1], theY);
840 myPosition[0] = theX;
841 myPosition[1] = theY;
844 CORBA::Double VISU::PointMap3d_i::GetPosX()
846 return myPosition[0];
849 CORBA::Double VISU::PointMap3d_i::GetPosY()
851 return myPosition[1];
854 void VISU::PointMap3d_i::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
856 bool anIsSameValue = VISU::CheckIsSameValue(myWidth, theWidth);
857 anIsSameValue &= VISU::CheckIsSameValue(myHeight, theHeight);
862 myHeight = theHeight;
865 CORBA::Double VISU::PointMap3d_i::GetHeight()
870 CORBA::Double VISU::PointMap3d_i::GetWidth()
875 void VISU::PointMap3d_i::SetNbColors(CORBA::Long theNbColors)
877 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
878 (GetSpecificPL(), &VISU_DeformedGridPL::SetNbColors, theNbColors));
881 CORBA::Long VISU::PointMap3d_i::GetNbColors()
883 return GetSpecificPL()->GetNbColors();
886 void VISU::PointMap3d_i::SetLabels(CORBA::Long theNbLabels)
888 if(myNumberOfLabels == theNbLabels)
891 myNumberOfLabels = theNbLabels;
894 CORBA::Long VISU::PointMap3d_i::GetLabels()
896 return myNumberOfLabels;
899 void VISU::PointMap3d_i::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theBarOrientation)
901 if(myBarOrientation == theBarOrientation)
904 myBarOrientation = theBarOrientation;
907 VISU::ColoredPrs3dBase::Orientation VISU::PointMap3d_i::GetBarOrientation()
909 return myBarOrientation;
912 //------------------- ScaledPrs3d Methods -----------------------
914 void VISU::PointMap3d_i::SetScaling(VISU::Scaling theScaling)
916 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
917 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaling, theScaling));
920 VISU::Scaling VISU::PointMap3d_i::GetScaling()
922 return VISU::Scaling(GetSpecificPL()->GetScaling());
925 //------------------- Check Table on Positive Values ------------
926 bool VISU::PointMap3d_i::IsPositiveTable()
928 SALOMEDS::GenericAttribute_var anAttr;
929 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
930 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
932 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
933 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
934 double aVal = aTableOfReal->GetValue(j, i);
942 //------------------- Plot3dBase Methods ------------------------
944 void VISU::PointMap3d_i::SetScaleFactor (CORBA::Double theScaleFactor)
946 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType>
947 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaleFactor, theScaleFactor));
950 CORBA::Double VISU::PointMap3d_i::GetScaleFactor ()
952 return myTablePL->GetScaleFactor();
955 void VISU::PointMap3d_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
957 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, bool>
958 (GetSpecificPL(), &VISU_DeformedGridPL::SetContourPrs, theIsContourPrs));
961 CORBA::Boolean VISU::PointMap3d_i::GetIsContourPrs()
963 return myTablePL->GetIsContourPrs();
966 void VISU::PointMap3d_i::SetNbOfContours (CORBA::Long theNb)
968 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
969 (GetSpecificPL(), &VISU_DeformedGridPL::SetNumberOfContours, theNb));
972 CORBA::Long VISU::PointMap3d_i::GetNbOfContours ()
974 return myTablePL->GetNumberOfContours();
977 //-------------------- Actor Factory Methods --------------------
979 bool VISU::PointMap3d_i::GetActiveState ()
981 return myIsActiveState;
984 void VISU::PointMap3d_i::SetActiveState ( bool theState )
986 myIsActiveState = theState;
989 void VISU::PointMap3d_i::RemoveActor (VISU_ActorBase* theActor)
991 myActorCollection->RemoveItem(theActor);
994 void VISU::PointMap3d_i::RemoveActors ()
996 ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
997 myActorCollection->RemoveAllItems();
1001 //-----------------------Text Properties & Label Properties------------------
1002 bool VISU::PointMap3d_i::IsBoldTitle()
1004 return myIsBoldTitle;
1007 //----------------------------------------------------------------------------
1008 void VISU::PointMap3d_i::SetBoldTitle(bool theIsBoldTitle)
1010 if(myIsBoldTitle == theIsBoldTitle)
1013 myIsBoldTitle = theIsBoldTitle;
1014 myParamsTime.Modified();
1017 //----------------------------------------------------------------------------
1018 bool VISU::PointMap3d_i::IsItalicTitle()
1020 return myIsItalicTitle;
1023 //----------------------------------------------------------------------------
1024 void VISU::PointMap3d_i::SetItalicTitle(bool theIsItalicTitle)
1026 if(myIsItalicTitle == theIsItalicTitle)
1029 myIsItalicTitle = theIsItalicTitle;
1030 myParamsTime.Modified();
1033 //----------------------------------------------------------------------------
1034 bool VISU::PointMap3d_i::IsShadowTitle()
1036 return myIsShadowTitle;
1039 //----------------------------------------------------------------------------
1040 void VISU::PointMap3d_i::SetShadowTitle(bool theIsShadowTitle)
1042 if(myIsShadowTitle == theIsShadowTitle)
1045 myIsShadowTitle = theIsShadowTitle;
1046 myParamsTime.Modified();
1049 //----------------------------------------------------------------------------
1050 int VISU::PointMap3d_i::GetTitFontType()
1052 return myTitFontType;
1055 //----------------------------------------------------------------------------
1056 void VISU::PointMap3d_i::SetTitFontType(int theTitFontType)
1058 if(myTitFontType == theTitFontType)
1061 myTitFontType = theTitFontType;
1062 myParamsTime.Modified();
1065 //----------------------------------------------------------------------------
1066 void VISU::PointMap3d_i::GetTitleColor(vtkFloatingPointType& theR,
1067 vtkFloatingPointType& theG,
1068 vtkFloatingPointType& theB)
1070 theR = myTitleColor[0];
1071 theG = myTitleColor[1];
1072 theB = myTitleColor[2];
1075 //----------------------------------------------------------------------------
1076 void VISU::PointMap3d_i::SetTitleColor(vtkFloatingPointType theR,
1077 vtkFloatingPointType theG,
1078 vtkFloatingPointType theB)
1080 bool anIsSameValue = VISU::CheckIsSameValue(myTitleColor[0], theR);
1081 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[1], theG);
1082 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[2], theB);
1086 myTitleColor[0] = theR;
1087 myTitleColor[1] = theG;
1088 myTitleColor[2] = theB;
1089 myParamsTime.Modified();
1092 //----------------------------------------------------------------------------
1093 bool VISU::PointMap3d_i::IsBoldLabel()
1095 return myIsBoldLabel;
1098 //----------------------------------------------------------------------------
1099 void VISU::PointMap3d_i::SetBoldLabel(bool theIsBoldLabel)
1101 if(myIsBoldLabel == theIsBoldLabel)
1104 myIsBoldLabel = theIsBoldLabel;
1105 myParamsTime.Modified();
1108 //----------------------------------------------------------------------------
1109 bool VISU::PointMap3d_i::IsItalicLabel()
1111 return myIsItalicLabel;
1114 //----------------------------------------------------------------------------
1115 void VISU::PointMap3d_i::SetItalicLabel(bool theIsItalicLabel)
1117 if(myIsItalicLabel == theIsItalicLabel)
1120 myIsItalicLabel = theIsItalicLabel;
1121 myParamsTime.Modified();
1124 //----------------------------------------------------------------------------
1125 bool VISU::PointMap3d_i::IsShadowLabel()
1127 return myIsShadowLabel;
1130 //----------------------------------------------------------------------------
1131 void VISU::PointMap3d_i::SetShadowLabel(bool theIsShadowLabel)
1133 if(myIsShadowLabel == theIsShadowLabel)
1136 myIsShadowLabel = theIsShadowLabel;
1137 myParamsTime.Modified();
1140 //----------------------------------------------------------------------------
1141 int VISU::PointMap3d_i::GetLblFontType()
1143 return myLblFontType;
1146 //----------------------------------------------------------------------------
1147 void VISU::PointMap3d_i::SetLblFontType(int theLblFontType)
1149 if(myLblFontType == theLblFontType)
1152 myLblFontType = theLblFontType;
1153 myParamsTime.Modified();
1156 //----------------------------------------------------------------------------
1157 void VISU::PointMap3d_i::GetLabelColor(vtkFloatingPointType& theR,
1158 vtkFloatingPointType& theG,
1159 vtkFloatingPointType& theB)
1161 theR = myLabelColor[0];
1162 theG = myLabelColor[1];
1163 theB = myLabelColor[2];
1166 //----------------------------------------------------------------------------
1167 void VISU::PointMap3d_i::SetLabelColor(vtkFloatingPointType theR,
1168 vtkFloatingPointType theG,
1169 vtkFloatingPointType theB)
1171 bool anIsSameValue = VISU::CheckIsSameValue(myLabelColor[0], theR);
1172 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[1], theG);
1173 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[2], theB);
1177 myLabelColor[0] = theR;
1178 myLabelColor[1] = theG;
1179 myLabelColor[2] = theB;
1180 myParamsTime.Modified();
1183 //----------------------------------------------------------------------------
1184 CORBA::Long VISU::PointMap3d_i::GetTitleSize()
1189 //----------------------------------------------------------------------------
1190 CORBA::Long VISU::PointMap3d_i::GetLabelSize()
1195 //----------------------------------------------------------------------------
1196 CORBA::Long VISU::PointMap3d_i::GetBarWidth()
1201 //----------------------------------------------------------------------------
1202 CORBA::Long VISU::PointMap3d_i::GetBarHeight()
1207 //----------------------------------------------------------------------------
1209 VISU::PointMap3d_i::SetLabelsFormat(const char* theFormat)
1211 if( myLabelsFormat != theFormat ){
1212 myLabelsFormat = theFormat;
1213 myParamsTime.Modified();
1217 //----------------------------------------------------------------------------
1218 char* VISU::PointMap3d_i::GetLabelsFormat()
1220 return CORBA::string_dup(myLabelsFormat.c_str());
1223 //----------------------------------------------------------------------------
1224 void VISU::PointMap3d_i::SetUnitsVisible(CORBA::Boolean isVisible)
1226 if( myIsUnits != isVisible ){
1227 myIsUnits = isVisible;
1228 myParamsTime.Modified();
1232 //----------------------------------------------------------------------------
1233 CORBA::Boolean VISU::PointMap3d_i::IsUnitsVisible()
1238 //----------------------------------------------------------------------------
1239 void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleSize,
1240 CORBA::Long theLabelSize,
1241 CORBA::Long theBarWidth, CORBA::Long theBarHeight)
1243 bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
1244 anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
1245 anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
1246 anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
1250 myTitleSize = theTitleSize;
1251 myLabelSize = theLabelSize;
1252 myBarWidth = theBarWidth;
1253 myBarHeight = theBarHeight;
1254 myParamsTime.Modified();