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_CutSegment_i.hh"
31 #include "VISU_Result_i.hh"
32 #include "VISU_ViewManager_i.hh"
33 #include "VISU_ScalarBarActor.hxx"
34 #include "SUIT_ResourceMgr.h"
36 #include "SALOME_Event.h"
37 #include "VISU_Prs3dUtils.hh"
38 #include "SPlot2d_Curve.h"
39 #include "VISU_PipeLineUtils.hxx"
41 #include "VISU_TableReader.hxx"
42 #include "VISU_ConvertorUtils.hxx"
43 #include "VISU_DeformedGridPL.hxx"
45 #include "SALOME_InteractiveObject.hxx"
46 #include "VISU_Gen_i.hh"
48 #include <vtkTextProperty.h>
49 #include <vtkActorCollection.h>
51 #include <boost/bind.hpp>
54 static int MYDEBUG = 0;
56 static int MYDEBUG = 0;
61 //----------------------------------------------------------------
63 //----------------------------------------------------------------
64 int VISU::PointMap3d_i::myNbPresent = 0;
65 const string VISU::PointMap3d_i::myComment = "POINTMAP3D";
69 QString VISU::PointMap3d_i::GenerateName()
71 return VISU::GenerateName( "Table3D - ", ++myNbPresent );
76 const char* VISU::PointMap3d_i::GetComment() const
78 return myComment.c_str();
83 VISU::PointMap3d_i::PointMap3d_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry )
84 : Table_i(theStudy, theObjectEntry),
85 myActorCollection(vtkActorCollection::New()),
88 if(MYDEBUG) MESSAGE("PointMap3d_i::PointMap3d_i - this = "<<this);
89 SetStudyDocument(theStudy);
90 mySObj = theStudy->FindObjectID(theObjectEntry);
91 myOffset[0] = myOffset[1] = myOffset[2] = 0;
92 myActorCollection->Delete();
97 VISU::PointMap3d_i::~PointMap3d_i()
99 if(MYDEBUG) MESSAGE("PointMap3d_i::~PointMap3d_i - this = "<<this);
102 //----------------------------------------------------------------------------
105 struct TInvokeSignalEvent: public SALOME_Event
107 typedef boost::signal0<void> TSignal;
108 const TSignal& mySignal;
110 TInvokeSignalEvent(const TSignal& theSignal):
123 //----------------------------------------------------------------------------
126 ::SetTitle( const char* theTitle )
128 SetName( theTitle, true );
131 //----------------------------------------------------------------------------
136 return CORBA::string_dup( GetName().c_str() );
139 //----------------------------------------------------------------------------
140 SALOMEDS::SObject_var
147 //----------------------------------------------------------------------------
152 CORBA::String_var anEntry = mySObj->GetID();
156 //----------------------------------------------------------------------------
157 Handle(SALOME_InteractiveObject)
162 myIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str());
167 //----------------------------------------------------------------------------
169 Creates table3d object
171 VISU::Storable* VISU::PointMap3d_i::Create()
174 SetName(GetTableTitle().toLatin1().constData(), false);
176 if ( GetName() == "" ) {
177 if ( !mySObj->_is_nil() ) {
178 CutLinesBase_i* pCutLines = NULL;
179 CORBA::Object_var anObj = SObjectToObject(mySObj);
180 if(!CORBA::is_nil(anObj)){
181 VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
182 if(!aCutLines->_is_nil())
183 pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
186 if (mySObj->GetName()) SetName(mySObj->GetName(), false);
190 if ( GetName() == "" )
191 SetName(GenerateName().toLatin1().constData(), false);
194 myTablePL = VISU_DeformedGridPL::New();
195 myTablePL->SetPolyDataIDMapper(GetTableIDMapper());
198 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
200 bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true );
201 SetUnitsVisible(isUnits);
205 if( aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false) )
206 SetScaling(VISU::LOGARITHMIC);
208 SetScaling(VISU::LINEAR);
210 int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 );
211 SetNbColors(aNumberOfColors);
213 int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
214 UseFixedRange(aRangeType == 1);
216 float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0);
217 float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0);
218 SetRange(aMin, aMax);
221 int lp = aResourceMgr->integerValue( "VISU", "scalar_bar_label_precision", 3 );
222 SetLabelsFormat( VISU::ToFormat( lp ).c_str() );
225 int anOrientation = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0);
226 if(anOrientation == 1)
227 SetBarOrientation(VISU::ColoredPrs3dBase::HORIZONTAL);
229 SetBarOrientation(VISU::ColoredPrs3dBase::VERTICAL);
232 QString propertyName = QString( "scalar_bar_%1_" ).arg( anOrientation == 0 ? "vertical" : "horizontal" );
234 vtkFloatingPointType aXorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.01 : 0.2;
235 aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin);
236 myPosition[0] = aXorigin;
238 vtkFloatingPointType aYorigin = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL) ? 0.1 : 0.012;
239 aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin);
240 myPosition[1] = aYorigin;
243 myWidth = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.1 : 0.6;
244 myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth);
246 myHeight = (myBarOrientation == VISU::ColoredPrs3dBase::VERTICAL)? 0.8:0.12;
247 myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight);
249 myTitleSize = aResourceMgr->doubleValue("VISU", propertyName + "title_size", 0);
250 myLabelSize = aResourceMgr->doubleValue("VISU", propertyName + "label_size", 0);
251 myBarWidth = aResourceMgr->doubleValue("VISU", propertyName + "bar_width", 0);
252 myBarHeight = aResourceMgr->doubleValue("VISU", propertyName + "bar_height", 0);
255 myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 );
257 // Fonts properties definition
258 myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true;
259 myTitFontType = VTK_ARIAL;
261 if(aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" )){
262 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
263 if ( f.family() == "Arial" )
264 myTitFontType = VTK_ARIAL;
265 else if ( f.family() == "Courier" )
266 myTitFontType = VTK_COURIER;
267 else if ( f.family() == "Times" )
268 myTitFontType = VTK_TIMES;
270 myIsBoldTitle = f.bold();
271 myIsItalicTitle = f.italic();
272 myIsShadowTitle = f.overline();
275 QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
277 myTitleColor[0] = aTextColor.red() / 255;
278 myTitleColor[1] = aTextColor.green() / 255;
279 myTitleColor[2] = aTextColor.blue() / 255;
281 myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true;
282 myLblFontType = VTK_ARIAL;
284 if( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" )){
285 QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
286 if ( f.family() == "Arial" )
287 myLblFontType = VTK_ARIAL;
288 else if ( f.family() == "Courier" )
289 myLblFontType = VTK_COURIER;
290 else if ( f.family() == "Times" )
291 myLblFontType = VTK_TIMES;
293 myIsBoldLabel = f.bold();
294 myIsItalicLabel = f.italic();
295 myIsShadowLabel = f.overline();
298 QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
300 myLabelColor[0] = aLabelColor.red() / 255;
301 myLabelColor[1] = aLabelColor.green() / 255;
302 myLabelColor[2] = aLabelColor.blue() / 255;
304 // scalar bar default position
305 bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
308 aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
310 if(myBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL){
311 myPosition[1] += myHeight*(aPlace-1);
313 myPosition[0] += myWidth*(aPlace-1);
316 return Build( false );
327 //Initialisate table mapper
328 SALOMEDS::GenericAttribute_var anAttr;
329 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
330 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
332 PTableIDMapper aTableIDMapper( new TTableIDMapper() );
333 TTable2D& aTable2D = *aTableIDMapper;
335 aTable2D.myTitle = aTableOfReal->GetTitle();
337 SALOMEDS::StringSeq_var aColStrList = aTableOfReal->GetColumnTitles();
338 SALOMEDS::StringSeq_var aRowStrList = aTableOfReal->GetRowTitles();
340 for ( int i = 0; i < aRowStrList->length(); i++ ) {
341 aTable2D.myColumnTitles.push_back( aRowStrList[ i ].in() );
344 int aCols = aTableOfReal->GetNbColumns();
345 int aRows = aTableOfReal->GetNbRows();
347 for (int i=1; i<=aCols; i++) {
349 aRow.myTitle = aColStrList[ i-1 ].in();
350 for (int j=1; j<=aRows; j++) {
351 double aVal = aTableOfReal->GetValue(j, i);
352 QString aValStr = QString::number(aVal);
353 aRow.myValues.push_back( aValStr.toLatin1().constData() );
355 if( aRow.myValues.size() > 0 )
356 aTable2D.myRows.push_back( aRow );
359 return aTableIDMapper;
365 VISU_PointMap3dActor* VISU::PointMap3d_i::CreateActor()
367 VISU_PointMap3dActor* anActor = VISU_PointMap3dActor::New();
368 anActor->SetPipeLine(myTablePL);
369 anActor->SetFactory(this);
371 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
372 int aDispMode = aResourceMgr->integerValue("VISU", "point_map_represent", 2);
373 bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_map_shrink", false);
374 anActor->SetRepresentation(aDispMode);
375 if (toShrink) anActor->SetShrink();
377 Handle (SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(GetEntry().c_str(), "VISU", GetName().c_str());
378 anActor->setIO(anIO);
380 myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,anActor));
381 // myRemoveActorsFromRendererSignal.connect(boost::bind(&VISU_Actor::RemoveFromRender,anActor));
383 myActorCollection->AddItem(anActor);
385 UpdateActor( anActor );
393 void VISU::PointMap3d_i::UpdateActor(VISU_ActorBase* theActor)
395 if(VISU_PointMap3dActor* anActor = dynamic_cast<VISU_PointMap3dActor*>(theActor)){
397 VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
398 aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable());
399 aScalarBar->SetTitle(GetTitle());
400 aScalarBar->SetOrientation(GetBarOrientation());
401 aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
402 aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY());
403 aScalarBar->SetWidth(GetWidth());
404 aScalarBar->SetHeight(GetHeight());
405 aScalarBar->SetNumberOfLabels(GetLabels());
406 aScalarBar->SetRatios(myTitleSize, myLabelSize,
407 myBarWidth, myBarHeight);
408 aScalarBar->SetNumberOfLabels(GetLabels());
409 aScalarBar->SetLabelFormat(GetLabelsFormat());
411 vtkFloatingPointType anRGB[3];
413 vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
414 aTitleProp->SetFontFamily(GetTitFontType());
416 GetTitleColor(anRGB[0],anRGB[1],anRGB[2]);
417 aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
419 IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
420 IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
421 IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
423 vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
424 aLabelProp->SetFontFamily(GetLblFontType());
426 GetLabelColor(anRGB[0],anRGB[1],anRGB[2]);
427 aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
429 IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
430 IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
431 IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
433 aScalarBar->Modified();
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 myParamsTime.Modified();
608 return Build( true );
611 Flushes table data into stream
613 void VISU::PointMap3d_i::ToStream( std::ostringstream& theStr )
615 Storable::DataToStream( theStr, "myName", GetName().c_str() );
616 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
617 Storable::DataToStream( theStr, "myOrientation", myOrientation );
619 Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
620 Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
621 Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
623 Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
624 Storable::DataToStream( theStr, "myBarOrientation", myBarOrientation );
626 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
627 Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
628 Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
629 Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
630 Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
631 Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
632 Storable::DataToStream( theStr, "myWidth", myWidth );
633 Storable::DataToStream( theStr, "myHeight", myHeight );
634 Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
635 Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
636 Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
637 Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
639 Storable::DataToStream( theStr, "myTitFontType", myTitFontType );
640 Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle );
641 Storable::DataToStream( theStr, "myIsItalicTitle", myIsItalicTitle );
642 Storable::DataToStream( theStr, "myIsShadowTitle", myIsShadowTitle );
643 Storable::DataToStream( theStr, "myTitleColor[0]", myTitleColor[0] );
644 Storable::DataToStream( theStr, "myTitleColor[1]", myTitleColor[1] );
645 Storable::DataToStream( theStr, "myTitleColor[2]", myTitleColor[2] );
647 Storable::DataToStream( theStr, "myLblFontType", myLblFontType );
648 Storable::DataToStream( theStr, "myIsBoldLabel", myIsBoldLabel );
649 Storable::DataToStream( theStr, "myIsItalicLabel", myIsItalicLabel );
650 Storable::DataToStream( theStr, "myIsShadowLabel", myIsShadowLabel );
651 Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] );
652 Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] );
653 Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] );
656 Called from engine to restore table from the file
658 VISU::Storable* VISU::PointMap3d_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
659 const Storable::TRestoringMap& theMap,
660 const std::string& thePrefix,
661 CORBA::Boolean theIsMultiFile)
663 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
664 VISU::PointMap3d_i* pResent = new VISU::PointMap3d_i( aStudy, "" );
665 return pResent->Restore( theMap, theSObject);
668 Gets title for the original table object
670 QString VISU::PointMap3d_i::GetTableTitle()
672 SALOMEDS::SObject_var SO = mySObj;
673 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
674 SALOMEDS::GenericAttribute_var anAttr;
675 SALOMEDS::AttributeTableOfInteger_var anInt;
676 SALOMEDS::AttributeTableOfReal_var aReal;
677 if ( !SO->_is_nil() ) {
678 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
679 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
680 CORBA::String_var aString = anInt->GetTitle();
683 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
684 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
685 CORBA::String_var aString = aReal->GetTitle();
692 //---------------------------------------------------------------
693 void VISU::PointMap3d_i::RemoveFromStudy()
695 struct TRemoveFromStudy: public SALOME_Event
697 VISU::PointMap3d_i* myRemovable;
698 TRemoveFromStudy(VISU::PointMap3d_i* theRemovable):
699 myRemovable(theRemovable)
706 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
710 // Remove the table with all curves
711 ProcessVoidEvent(new TRemoveFromStudy(this));
714 //----------------------------------------------------------------
715 void VISU::PointMap3d_i::SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz)
720 myParamsTime.Modified();
723 void VISU::PointMap3d_i::GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz)
730 CORBA::Float VISU::PointMap3d_i::GetMemorySize()
732 CORBA::Float aSize = GetSpecificPL()->GetMemorySize();
734 int anEnd = myActorCollection->GetNumberOfItems();
735 for(int anId = 0; anId < anEnd; anId++)
736 if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
737 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
738 aSize += anActor->GetMemorySize();
739 //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
742 // Convert to mega bytes
743 return aSize / (1024.0 * 1024.0);
746 //------------------ ColoredPrs3dBase Methods --------------------
747 CORBA::Double VISU::PointMap3d_i::GetMin()
749 return myTablePL->GetScalarRange()[0];
752 CORBA::Double VISU::PointMap3d_i::GetMinTableValue()
754 SALOMEDS::GenericAttribute_var anAttr;
755 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
756 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
757 double aMin = aTableOfReal->GetValue(1, 1);
759 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
760 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
761 double aVal = aTableOfReal->GetValue(j, i);
769 CORBA::Double VISU::PointMap3d_i::GetMaxTableValue()
771 SALOMEDS::GenericAttribute_var anAttr;
772 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
773 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
774 double aMax = aTableOfReal->GetValue(1, 1);
776 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
777 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
778 double aVal = aTableOfReal->GetValue(j, i);
786 CORBA::Double VISU::PointMap3d_i::GetMax()
788 return myTablePL->GetScalarRange()[1];
791 void VISU::PointMap3d_i::SetRange(CORBA::Double theMin, CORBA::Double theMax)
793 vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
794 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType*>
795 (GetSpecificPL(), &VISU_DeformedGridPL::SetScalarRange, aScalarRange));
800 CORBA::Double VISU::PointMap3d_i::GetSourceMin()
802 vtkFloatingPointType aRange[2];
803 GetSpecificPL()->GetSourceRange(aRange);
807 CORBA::Double VISU::PointMap3d_i::GetSourceMax()
809 vtkFloatingPointType aRange[2];
810 GetSpecificPL()->GetSourceRange(aRange);
814 void VISU::PointMap3d_i::SetSourceRange()
816 GetSpecificPL()->SetSourceRange();
817 ProcessVoidEvent(new TVoidMemFunEvent<VISU_DeformedGridPL>
818 (GetSpecificPL(), &VISU_DeformedGridPL::SetSourceRange));
820 UseFixedRange(false);
823 CORBA::Boolean VISU::PointMap3d_i::IsRangeFixed()
825 return myIsFixedRange;
828 void VISU::PointMap3d_i::UseFixedRange(bool theRange)
830 if(myIsFixedRange == theRange)
833 myIsFixedRange = theRange;
836 void VISU::PointMap3d_i::SetPosition(CORBA::Double theX, CORBA::Double theY)
838 bool anIsSameValue = VISU::CheckIsSameValue(myPosition[0], theX);
839 anIsSameValue &= VISU::CheckIsSameValue(myPosition[1], theY);
843 myPosition[0] = theX;
844 myPosition[1] = theY;
845 myParamsTime.Modified();
848 CORBA::Double VISU::PointMap3d_i::GetPosX()
850 return myPosition[0];
853 CORBA::Double VISU::PointMap3d_i::GetPosY()
855 return myPosition[1];
858 void VISU::PointMap3d_i::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
860 bool anIsSameValue = VISU::CheckIsSameValue(myWidth, theWidth);
861 anIsSameValue &= VISU::CheckIsSameValue(myHeight, theHeight);
866 myHeight = theHeight;
867 myParamsTime.Modified();
870 CORBA::Double VISU::PointMap3d_i::GetHeight()
875 CORBA::Double VISU::PointMap3d_i::GetWidth()
880 void VISU::PointMap3d_i::SetNbColors(CORBA::Long theNbColors)
882 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
883 (GetSpecificPL(), &VISU_DeformedGridPL::SetNbColors, theNbColors));
886 CORBA::Long VISU::PointMap3d_i::GetNbColors()
888 return GetSpecificPL()->GetNbColors();
891 void VISU::PointMap3d_i::SetLabels(CORBA::Long theNbLabels)
893 if(myNumberOfLabels == theNbLabels)
896 myNumberOfLabels = theNbLabels;
899 CORBA::Long VISU::PointMap3d_i::GetLabels()
901 return myNumberOfLabels;
904 void VISU::PointMap3d_i::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theBarOrientation)
906 if(myBarOrientation == theBarOrientation)
909 if ( ( theBarOrientation == VISU::ColoredPrs3dBase::VERTICAL && myHeight < myWidth ) ||
910 ( theBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL && myHeight > myWidth ) ) {
911 vtkFloatingPointType tmp = myHeight;
916 myBarOrientation = theBarOrientation;
917 myParamsTime.Modified();
920 VISU::ColoredPrs3dBase::Orientation VISU::PointMap3d_i::GetBarOrientation()
922 return myBarOrientation;
925 //------------------- ScaledPrs3d Methods -----------------------
927 void VISU::PointMap3d_i::SetScaling(VISU::Scaling theScaling)
929 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
930 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaling, theScaling));
933 VISU::Scaling VISU::PointMap3d_i::GetScaling()
935 return VISU::Scaling(GetSpecificPL()->GetScaling());
938 //------------------- Check Table on Positive Values ------------
939 bool VISU::PointMap3d_i::IsPositiveTable()
941 SALOMEDS::GenericAttribute_var anAttr;
942 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
943 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
945 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
946 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
947 double aVal = aTableOfReal->GetValue(j, i);
955 //------------------- Plot3dBase Methods ------------------------
957 void VISU::PointMap3d_i::SetScaleFactor (CORBA::Double theScaleFactor)
959 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType>
960 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaleFactor, theScaleFactor));
963 CORBA::Double VISU::PointMap3d_i::GetScaleFactor ()
965 return myTablePL->GetScaleFactor();
968 void VISU::PointMap3d_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
970 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, bool>
971 (GetSpecificPL(), &VISU_DeformedGridPL::SetContourPrs, theIsContourPrs));
974 CORBA::Boolean VISU::PointMap3d_i::GetIsContourPrs()
976 return myTablePL->GetIsContourPrs();
979 void VISU::PointMap3d_i::SetNbOfContours (CORBA::Long theNb)
981 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
982 (GetSpecificPL(), &VISU_DeformedGridPL::SetNumberOfContours, theNb));
985 CORBA::Long VISU::PointMap3d_i::GetNbOfContours ()
987 return myTablePL->GetNumberOfContours();
990 //-------------------- Actor Factory Methods --------------------
992 bool VISU::PointMap3d_i::GetActiveState ()
994 return myIsActiveState;
997 void VISU::PointMap3d_i::SetActiveState ( bool theState )
999 myIsActiveState = theState;
1002 void VISU::PointMap3d_i::RemoveActor (VISU_ActorBase* theActor)
1004 myActorCollection->RemoveItem(theActor);
1007 void VISU::PointMap3d_i::RemoveActors ()
1009 ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
1010 myActorCollection->RemoveAllItems();
1014 //-----------------------Text Properties & Label Properties------------------
1015 bool VISU::PointMap3d_i::IsBoldTitle()
1017 return myIsBoldTitle;
1020 //----------------------------------------------------------------------------
1021 void VISU::PointMap3d_i::SetBoldTitle(bool theIsBoldTitle)
1023 if(myIsBoldTitle == theIsBoldTitle)
1026 myIsBoldTitle = theIsBoldTitle;
1027 myParamsTime.Modified();
1030 //----------------------------------------------------------------------------
1031 bool VISU::PointMap3d_i::IsItalicTitle()
1033 return myIsItalicTitle;
1036 //----------------------------------------------------------------------------
1037 void VISU::PointMap3d_i::SetItalicTitle(bool theIsItalicTitle)
1039 if(myIsItalicTitle == theIsItalicTitle)
1042 myIsItalicTitle = theIsItalicTitle;
1043 myParamsTime.Modified();
1046 //----------------------------------------------------------------------------
1047 bool VISU::PointMap3d_i::IsShadowTitle()
1049 return myIsShadowTitle;
1052 //----------------------------------------------------------------------------
1053 void VISU::PointMap3d_i::SetShadowTitle(bool theIsShadowTitle)
1055 if(myIsShadowTitle == theIsShadowTitle)
1058 myIsShadowTitle = theIsShadowTitle;
1059 myParamsTime.Modified();
1062 //----------------------------------------------------------------------------
1063 int VISU::PointMap3d_i::GetTitFontType()
1065 return myTitFontType;
1068 //----------------------------------------------------------------------------
1069 void VISU::PointMap3d_i::SetTitFontType(int theTitFontType)
1071 if(myTitFontType == theTitFontType)
1074 myTitFontType = theTitFontType;
1075 myParamsTime.Modified();
1078 //----------------------------------------------------------------------------
1079 void VISU::PointMap3d_i::GetTitleColor(vtkFloatingPointType& theR,
1080 vtkFloatingPointType& theG,
1081 vtkFloatingPointType& theB)
1083 theR = myTitleColor[0];
1084 theG = myTitleColor[1];
1085 theB = myTitleColor[2];
1088 //----------------------------------------------------------------------------
1089 void VISU::PointMap3d_i::SetTitleColor(vtkFloatingPointType theR,
1090 vtkFloatingPointType theG,
1091 vtkFloatingPointType theB)
1093 bool anIsSameValue = VISU::CheckIsSameValue(myTitleColor[0], theR);
1094 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[1], theG);
1095 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[2], theB);
1099 myTitleColor[0] = theR;
1100 myTitleColor[1] = theG;
1101 myTitleColor[2] = theB;
1102 myParamsTime.Modified();
1105 //----------------------------------------------------------------------------
1106 bool VISU::PointMap3d_i::IsBoldLabel()
1108 return myIsBoldLabel;
1111 //----------------------------------------------------------------------------
1112 void VISU::PointMap3d_i::SetBoldLabel(bool theIsBoldLabel)
1114 if(myIsBoldLabel == theIsBoldLabel)
1117 myIsBoldLabel = theIsBoldLabel;
1118 myParamsTime.Modified();
1121 //----------------------------------------------------------------------------
1122 bool VISU::PointMap3d_i::IsItalicLabel()
1124 return myIsItalicLabel;
1127 //----------------------------------------------------------------------------
1128 void VISU::PointMap3d_i::SetItalicLabel(bool theIsItalicLabel)
1130 if(myIsItalicLabel == theIsItalicLabel)
1133 myIsItalicLabel = theIsItalicLabel;
1134 myParamsTime.Modified();
1137 //----------------------------------------------------------------------------
1138 bool VISU::PointMap3d_i::IsShadowLabel()
1140 return myIsShadowLabel;
1143 //----------------------------------------------------------------------------
1144 void VISU::PointMap3d_i::SetShadowLabel(bool theIsShadowLabel)
1146 if(myIsShadowLabel == theIsShadowLabel)
1149 myIsShadowLabel = theIsShadowLabel;
1150 myParamsTime.Modified();
1153 //----------------------------------------------------------------------------
1154 int VISU::PointMap3d_i::GetLblFontType()
1156 return myLblFontType;
1159 //----------------------------------------------------------------------------
1160 void VISU::PointMap3d_i::SetLblFontType(int theLblFontType)
1162 if(myLblFontType == theLblFontType)
1165 myLblFontType = theLblFontType;
1166 myParamsTime.Modified();
1169 //----------------------------------------------------------------------------
1170 void VISU::PointMap3d_i::GetLabelColor(vtkFloatingPointType& theR,
1171 vtkFloatingPointType& theG,
1172 vtkFloatingPointType& theB)
1174 theR = myLabelColor[0];
1175 theG = myLabelColor[1];
1176 theB = myLabelColor[2];
1179 //----------------------------------------------------------------------------
1180 void VISU::PointMap3d_i::SetLabelColor(vtkFloatingPointType theR,
1181 vtkFloatingPointType theG,
1182 vtkFloatingPointType theB)
1184 bool anIsSameValue = VISU::CheckIsSameValue(myLabelColor[0], theR);
1185 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[1], theG);
1186 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[2], theB);
1190 myLabelColor[0] = theR;
1191 myLabelColor[1] = theG;
1192 myLabelColor[2] = theB;
1193 myParamsTime.Modified();
1196 //----------------------------------------------------------------------------
1197 CORBA::Long VISU::PointMap3d_i::GetTitleSize()
1202 //----------------------------------------------------------------------------
1203 CORBA::Long VISU::PointMap3d_i::GetLabelSize()
1208 //----------------------------------------------------------------------------
1209 CORBA::Long VISU::PointMap3d_i::GetBarWidth()
1214 //----------------------------------------------------------------------------
1215 CORBA::Long VISU::PointMap3d_i::GetBarHeight()
1220 //----------------------------------------------------------------------------
1222 VISU::PointMap3d_i::SetLabelsFormat(const char* theFormat)
1224 if( myLabelsFormat != theFormat ){
1225 myLabelsFormat = theFormat;
1226 myParamsTime.Modified();
1230 //----------------------------------------------------------------------------
1231 char* VISU::PointMap3d_i::GetLabelsFormat()
1233 return CORBA::string_dup(myLabelsFormat.c_str());
1236 //----------------------------------------------------------------------------
1237 void VISU::PointMap3d_i::SetUnitsVisible(CORBA::Boolean isVisible)
1239 if( myIsUnits != isVisible ){
1240 myIsUnits = isVisible;
1241 myParamsTime.Modified();
1245 //----------------------------------------------------------------------------
1246 CORBA::Boolean VISU::PointMap3d_i::IsUnitsVisible()
1251 //----------------------------------------------------------------------------
1252 void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleSize,
1253 CORBA::Long theLabelSize,
1254 CORBA::Long theBarWidth, CORBA::Long theBarHeight)
1256 bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
1257 anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
1258 anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
1259 anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
1263 myTitleSize = theTitleSize;
1264 myLabelSize = theLabelSize;
1265 myBarWidth = theBarWidth;
1266 myBarHeight = theBarHeight;
1267 myParamsTime.Modified();