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 if(MYDEBUG) MESSAGE(GetComment());
556 SetName(VISU::Storable::FindValue(theMap,"myName").toLatin1().constData(), false);
557 myTitle = VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData();
558 myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() );
559 mySObj = SALOMEDS::SObject::_duplicate(SO);
562 myTablePL = VISU_DeformedGridPL::New();
563 myTablePL->SetPolyDataIDMapper(GetTableIDMapper());
566 //Restore Other Values
568 float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble();
569 float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
570 SetRange(aMin, aMax);
572 UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt());
574 SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
575 SetUnitsVisible(VISU::Storable::FindValue(theMap,"myUnitsVisible", "1").toInt());
576 SetLabelsFormat(VISU::Storable::FindValue(theMap,"myLabelsFormat", "%-#6.3g").toLatin1().constData());
577 SetBarOrientation((VISU::ColoredPrs3dBase::Orientation)VISU::Storable::FindValue(theMap,"myBarOrientation").toInt());
579 SetTitle(VISU::Storable::FindValue(theMap,"myTitle").toLatin1().constData());
580 myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt();
581 myPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
582 myPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
583 myWidth = VISU::Storable::FindValue(theMap,"myWidth").toDouble();
584 myHeight = VISU::Storable::FindValue(theMap,"myHeight").toDouble();
585 myTitleSize = VISU::Storable::FindValue(theMap,"myTitleSize").toInt();
586 myLabelSize = VISU::Storable::FindValue(theMap,"myLabelSize").toInt();
587 myBarWidth = VISU::Storable::FindValue(theMap,"myBarWidth").toInt();
588 myBarHeight = VISU::Storable::FindValue(theMap,"myBarHeight").toInt();
590 myTitFontType = VISU::Storable::FindValue(theMap,"myTitFontType").toInt();
591 myIsBoldTitle = VISU::Storable::FindValue(theMap,"myIsBoldTitle").toInt();
592 myIsItalicTitle = VISU::Storable::FindValue(theMap,"myIsItalicTitle").toInt();
593 myIsShadowTitle = VISU::Storable::FindValue(theMap,"myIsShadowTitle").toInt();
594 myTitleColor[0] = VISU::Storable::FindValue(theMap,"myTitleColor[0]").toFloat();
595 myTitleColor[1] = VISU::Storable::FindValue(theMap,"myTitleColor[1]").toFloat();
596 myTitleColor[2] = VISU::Storable::FindValue(theMap,"myTitleColor[2]").toFloat();
598 myLblFontType = VISU::Storable::FindValue(theMap,"myLblFontType").toInt();
599 myIsBoldLabel = VISU::Storable::FindValue(theMap,"myIsBoldLabel").toInt();
600 myIsItalicLabel = VISU::Storable::FindValue(theMap,"myIsItalicLabel").toInt();
601 myIsShadowLabel = VISU::Storable::FindValue(theMap,"myIsShadowLabel").toInt();
602 myLabelColor[0] = VISU::Storable::FindValue(theMap,"myLabelColor[0]").toFloat();
603 myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat();
604 myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat();
606 myParamsTime.Modified();
607 return Build( true );
610 Flushes table data into stream
612 void VISU::PointMap3d_i::ToStream( std::ostringstream& theStr )
614 Storable::DataToStream( theStr, "myName", GetName().c_str() );
615 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
616 Storable::DataToStream( theStr, "myOrientation", myOrientation );
618 Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
619 Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
620 Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
622 Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
623 Storable::DataToStream( theStr, "myBarOrientation", myBarOrientation );
625 Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
626 Storable::DataToStream( theStr, "myUnitsVisible", myIsUnits );
627 Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
628 Storable::DataToStream( theStr, "myLabelsFormat", myLabelsFormat.c_str() );
629 Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
630 Storable::DataToStream( theStr, "myPosition[1]", myPosition[1] );
631 Storable::DataToStream( theStr, "myWidth", myWidth );
632 Storable::DataToStream( theStr, "myHeight", myHeight );
633 Storable::DataToStream( theStr, "myTitleSize", myTitleSize );
634 Storable::DataToStream( theStr, "myLabelSize", myLabelSize );
635 Storable::DataToStream( theStr, "myBarWidth", myBarWidth );
636 Storable::DataToStream( theStr, "myBarHeight", myBarHeight );
638 Storable::DataToStream( theStr, "myTitFontType", myTitFontType );
639 Storable::DataToStream( theStr, "myIsBoldTitle", myIsBoldTitle );
640 Storable::DataToStream( theStr, "myIsItalicTitle", myIsItalicTitle );
641 Storable::DataToStream( theStr, "myIsShadowTitle", myIsShadowTitle );
642 Storable::DataToStream( theStr, "myTitleColor[0]", myTitleColor[0] );
643 Storable::DataToStream( theStr, "myTitleColor[1]", myTitleColor[1] );
644 Storable::DataToStream( theStr, "myTitleColor[2]", myTitleColor[2] );
646 Storable::DataToStream( theStr, "myLblFontType", myLblFontType );
647 Storable::DataToStream( theStr, "myIsBoldLabel", myIsBoldLabel );
648 Storable::DataToStream( theStr, "myIsItalicLabel", myIsItalicLabel );
649 Storable::DataToStream( theStr, "myIsShadowLabel", myIsShadowLabel );
650 Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] );
651 Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] );
652 Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] );
655 Called from engine to restore table from the file
657 VISU::Storable* VISU::PointMap3d_i::StorableEngine(SALOMEDS::SObject_ptr theSObject,
658 const Storable::TRestoringMap& theMap,
659 const std::string& thePrefix,
660 CORBA::Boolean theIsMultiFile)
662 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
663 VISU::PointMap3d_i* pResent = new VISU::PointMap3d_i( aStudy, "" );
664 return pResent->Restore( theMap, theSObject);
667 Gets title for the original table object
669 QString VISU::PointMap3d_i::GetTableTitle()
671 SALOMEDS::SObject_var SO = mySObj;
672 SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
673 SALOMEDS::GenericAttribute_var anAttr;
674 SALOMEDS::AttributeTableOfInteger_var anInt;
675 SALOMEDS::AttributeTableOfReal_var aReal;
676 if ( !SO->_is_nil() ) {
677 if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
678 anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
679 CORBA::String_var aString = anInt->GetTitle();
682 else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
683 aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
684 CORBA::String_var aString = aReal->GetTitle();
691 //---------------------------------------------------------------
692 void VISU::PointMap3d_i::RemoveFromStudy()
694 struct TRemoveFromStudy: public SALOME_Event
696 VISU::PointMap3d_i* myRemovable;
697 TRemoveFromStudy(VISU::PointMap3d_i* theRemovable):
698 myRemovable(theRemovable)
705 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
709 // Remove the table with all curves
710 ProcessVoidEvent(new TRemoveFromStudy(this));
713 //----------------------------------------------------------------
714 void VISU::PointMap3d_i::SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz)
719 myParamsTime.Modified();
722 void VISU::PointMap3d_i::GetOffset(CORBA::Float& theDx, CORBA::Float& theDy, CORBA::Float& theDz)
729 CORBA::Float VISU::PointMap3d_i::GetMemorySize()
731 CORBA::Float aSize = GetSpecificPL()->GetMemorySize();
733 int anEnd = myActorCollection->GetNumberOfItems();
734 for(int anId = 0; anId < anEnd; anId++)
735 if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
736 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
737 aSize += anActor->GetMemorySize();
738 //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
741 // Convert to mega bytes
742 return aSize / (1024.0 * 1024.0);
745 //------------------ ColoredPrs3dBase Methods --------------------
746 CORBA::Double VISU::PointMap3d_i::GetMin()
748 return myTablePL->GetScalarRange()[0];
751 CORBA::Double VISU::PointMap3d_i::GetMinTableValue()
753 SALOMEDS::GenericAttribute_var anAttr;
754 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
755 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
756 double aMin = aTableOfReal->GetValue(1, 1);
758 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
759 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
760 double aVal = aTableOfReal->GetValue(j, i);
768 CORBA::Double VISU::PointMap3d_i::GetMaxTableValue()
770 SALOMEDS::GenericAttribute_var anAttr;
771 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
772 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
773 double aMax = aTableOfReal->GetValue(1, 1);
775 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
776 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
777 double aVal = aTableOfReal->GetValue(j, i);
785 CORBA::Double VISU::PointMap3d_i::GetMax()
787 return myTablePL->GetScalarRange()[1];
790 void VISU::PointMap3d_i::SetRange(CORBA::Double theMin, CORBA::Double theMax)
792 vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
793 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType*>
794 (GetSpecificPL(), &VISU_DeformedGridPL::SetScalarRange, aScalarRange));
799 CORBA::Double VISU::PointMap3d_i::GetSourceMin()
801 vtkFloatingPointType aRange[2];
802 GetSpecificPL()->GetSourceRange(aRange);
806 CORBA::Double VISU::PointMap3d_i::GetSourceMax()
808 vtkFloatingPointType aRange[2];
809 GetSpecificPL()->GetSourceRange(aRange);
813 void VISU::PointMap3d_i::SetSourceRange()
815 GetSpecificPL()->SetSourceRange();
816 ProcessVoidEvent(new TVoidMemFunEvent<VISU_DeformedGridPL>
817 (GetSpecificPL(), &VISU_DeformedGridPL::SetSourceRange));
819 UseFixedRange(false);
822 CORBA::Boolean VISU::PointMap3d_i::IsRangeFixed()
824 return myIsFixedRange;
827 void VISU::PointMap3d_i::UseFixedRange(bool theRange)
829 if(myIsFixedRange == theRange)
832 myIsFixedRange = theRange;
835 void VISU::PointMap3d_i::SetPosition(CORBA::Double theX, CORBA::Double theY)
837 bool anIsSameValue = VISU::CheckIsSameValue(myPosition[0], theX);
838 anIsSameValue &= VISU::CheckIsSameValue(myPosition[1], theY);
842 myPosition[0] = theX;
843 myPosition[1] = theY;
844 myParamsTime.Modified();
847 CORBA::Double VISU::PointMap3d_i::GetPosX()
849 return myPosition[0];
852 CORBA::Double VISU::PointMap3d_i::GetPosY()
854 return myPosition[1];
857 void VISU::PointMap3d_i::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
859 bool anIsSameValue = VISU::CheckIsSameValue(myWidth, theWidth);
860 anIsSameValue &= VISU::CheckIsSameValue(myHeight, theHeight);
865 myHeight = theHeight;
866 myParamsTime.Modified();
869 CORBA::Double VISU::PointMap3d_i::GetHeight()
874 CORBA::Double VISU::PointMap3d_i::GetWidth()
879 void VISU::PointMap3d_i::SetNbColors(CORBA::Long theNbColors)
881 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
882 (GetSpecificPL(), &VISU_DeformedGridPL::SetNbColors, theNbColors));
885 CORBA::Long VISU::PointMap3d_i::GetNbColors()
887 return GetSpecificPL()->GetNbColors();
890 void VISU::PointMap3d_i::SetLabels(CORBA::Long theNbLabels)
892 if(myNumberOfLabels == theNbLabels)
895 myNumberOfLabels = theNbLabels;
898 CORBA::Long VISU::PointMap3d_i::GetLabels()
900 return myNumberOfLabels;
903 void VISU::PointMap3d_i::SetBarOrientation(VISU::ColoredPrs3dBase::Orientation theBarOrientation)
905 if(myBarOrientation == theBarOrientation)
908 if ( ( theBarOrientation == VISU::ColoredPrs3dBase::VERTICAL && myHeight < myWidth ) ||
909 ( theBarOrientation == VISU::ColoredPrs3dBase::HORIZONTAL && myHeight > myWidth ) ) {
910 vtkFloatingPointType tmp = myHeight;
915 myBarOrientation = theBarOrientation;
916 myParamsTime.Modified();
919 VISU::ColoredPrs3dBase::Orientation VISU::PointMap3d_i::GetBarOrientation()
921 return myBarOrientation;
924 //------------------- ScaledPrs3d Methods -----------------------
926 void VISU::PointMap3d_i::SetScaling(VISU::Scaling theScaling)
928 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
929 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaling, theScaling));
932 VISU::Scaling VISU::PointMap3d_i::GetScaling()
934 return VISU::Scaling(GetSpecificPL()->GetScaling());
937 //------------------- Check Table on Positive Values ------------
938 bool VISU::PointMap3d_i::IsPositiveTable()
940 SALOMEDS::GenericAttribute_var anAttr;
941 mySObj->FindAttribute(anAttr, "AttributeTableOfReal");
942 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
944 for (int i=1; i<=aTableOfReal->GetNbColumns(); i++)
945 for (int j=1; j<=aTableOfReal->GetNbRows(); j++) {
946 double aVal = aTableOfReal->GetValue(j, i);
954 //------------------- Plot3dBase Methods ------------------------
956 void VISU::PointMap3d_i::SetScaleFactor (CORBA::Double theScaleFactor)
958 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, vtkFloatingPointType>
959 (GetSpecificPL(), &VISU_DeformedGridPL::SetScaleFactor, theScaleFactor));
962 CORBA::Double VISU::PointMap3d_i::GetScaleFactor ()
964 return myTablePL->GetScaleFactor();
967 void VISU::PointMap3d_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
969 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, bool>
970 (GetSpecificPL(), &VISU_DeformedGridPL::SetContourPrs, theIsContourPrs));
973 CORBA::Boolean VISU::PointMap3d_i::GetIsContourPrs()
975 return myTablePL->GetIsContourPrs();
978 void VISU::PointMap3d_i::SetNbOfContours (CORBA::Long theNb)
980 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedGridPL, int>
981 (GetSpecificPL(), &VISU_DeformedGridPL::SetNumberOfContours, theNb));
984 CORBA::Long VISU::PointMap3d_i::GetNbOfContours ()
986 return myTablePL->GetNumberOfContours();
989 //-------------------- Actor Factory Methods --------------------
991 bool VISU::PointMap3d_i::GetActiveState ()
993 return myIsActiveState;
996 void VISU::PointMap3d_i::SetActiveState ( bool theState )
998 myIsActiveState = theState;
1001 void VISU::PointMap3d_i::RemoveActor (VISU_ActorBase* theActor)
1003 myActorCollection->RemoveItem(theActor);
1006 void VISU::PointMap3d_i::RemoveActors ()
1008 ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
1009 myActorCollection->RemoveAllItems();
1013 //-----------------------Text Properties & Label Properties------------------
1014 bool VISU::PointMap3d_i::IsBoldTitle()
1016 return myIsBoldTitle;
1019 //----------------------------------------------------------------------------
1020 void VISU::PointMap3d_i::SetBoldTitle(bool theIsBoldTitle)
1022 if(myIsBoldTitle == theIsBoldTitle)
1025 myIsBoldTitle = theIsBoldTitle;
1026 myParamsTime.Modified();
1029 //----------------------------------------------------------------------------
1030 bool VISU::PointMap3d_i::IsItalicTitle()
1032 return myIsItalicTitle;
1035 //----------------------------------------------------------------------------
1036 void VISU::PointMap3d_i::SetItalicTitle(bool theIsItalicTitle)
1038 if(myIsItalicTitle == theIsItalicTitle)
1041 myIsItalicTitle = theIsItalicTitle;
1042 myParamsTime.Modified();
1045 //----------------------------------------------------------------------------
1046 bool VISU::PointMap3d_i::IsShadowTitle()
1048 return myIsShadowTitle;
1051 //----------------------------------------------------------------------------
1052 void VISU::PointMap3d_i::SetShadowTitle(bool theIsShadowTitle)
1054 if(myIsShadowTitle == theIsShadowTitle)
1057 myIsShadowTitle = theIsShadowTitle;
1058 myParamsTime.Modified();
1061 //----------------------------------------------------------------------------
1062 int VISU::PointMap3d_i::GetTitFontType()
1064 return myTitFontType;
1067 //----------------------------------------------------------------------------
1068 void VISU::PointMap3d_i::SetTitFontType(int theTitFontType)
1070 if(myTitFontType == theTitFontType)
1073 myTitFontType = theTitFontType;
1074 myParamsTime.Modified();
1077 //----------------------------------------------------------------------------
1078 void VISU::PointMap3d_i::GetTitleColor(vtkFloatingPointType& theR,
1079 vtkFloatingPointType& theG,
1080 vtkFloatingPointType& theB)
1082 theR = myTitleColor[0];
1083 theG = myTitleColor[1];
1084 theB = myTitleColor[2];
1087 //----------------------------------------------------------------------------
1088 void VISU::PointMap3d_i::SetTitleColor(vtkFloatingPointType theR,
1089 vtkFloatingPointType theG,
1090 vtkFloatingPointType theB)
1092 bool anIsSameValue = VISU::CheckIsSameValue(myTitleColor[0], theR);
1093 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[1], theG);
1094 anIsSameValue &= VISU::CheckIsSameValue(myTitleColor[2], theB);
1098 myTitleColor[0] = theR;
1099 myTitleColor[1] = theG;
1100 myTitleColor[2] = theB;
1101 myParamsTime.Modified();
1104 //----------------------------------------------------------------------------
1105 bool VISU::PointMap3d_i::IsBoldLabel()
1107 return myIsBoldLabel;
1110 //----------------------------------------------------------------------------
1111 void VISU::PointMap3d_i::SetBoldLabel(bool theIsBoldLabel)
1113 if(myIsBoldLabel == theIsBoldLabel)
1116 myIsBoldLabel = theIsBoldLabel;
1117 myParamsTime.Modified();
1120 //----------------------------------------------------------------------------
1121 bool VISU::PointMap3d_i::IsItalicLabel()
1123 return myIsItalicLabel;
1126 //----------------------------------------------------------------------------
1127 void VISU::PointMap3d_i::SetItalicLabel(bool theIsItalicLabel)
1129 if(myIsItalicLabel == theIsItalicLabel)
1132 myIsItalicLabel = theIsItalicLabel;
1133 myParamsTime.Modified();
1136 //----------------------------------------------------------------------------
1137 bool VISU::PointMap3d_i::IsShadowLabel()
1139 return myIsShadowLabel;
1142 //----------------------------------------------------------------------------
1143 void VISU::PointMap3d_i::SetShadowLabel(bool theIsShadowLabel)
1145 if(myIsShadowLabel == theIsShadowLabel)
1148 myIsShadowLabel = theIsShadowLabel;
1149 myParamsTime.Modified();
1152 //----------------------------------------------------------------------------
1153 int VISU::PointMap3d_i::GetLblFontType()
1155 return myLblFontType;
1158 //----------------------------------------------------------------------------
1159 void VISU::PointMap3d_i::SetLblFontType(int theLblFontType)
1161 if(myLblFontType == theLblFontType)
1164 myLblFontType = theLblFontType;
1165 myParamsTime.Modified();
1168 //----------------------------------------------------------------------------
1169 void VISU::PointMap3d_i::GetLabelColor(vtkFloatingPointType& theR,
1170 vtkFloatingPointType& theG,
1171 vtkFloatingPointType& theB)
1173 theR = myLabelColor[0];
1174 theG = myLabelColor[1];
1175 theB = myLabelColor[2];
1178 //----------------------------------------------------------------------------
1179 void VISU::PointMap3d_i::SetLabelColor(vtkFloatingPointType theR,
1180 vtkFloatingPointType theG,
1181 vtkFloatingPointType theB)
1183 bool anIsSameValue = VISU::CheckIsSameValue(myLabelColor[0], theR);
1184 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[1], theG);
1185 anIsSameValue &= VISU::CheckIsSameValue(myLabelColor[2], theB);
1189 myLabelColor[0] = theR;
1190 myLabelColor[1] = theG;
1191 myLabelColor[2] = theB;
1192 myParamsTime.Modified();
1195 //----------------------------------------------------------------------------
1196 CORBA::Long VISU::PointMap3d_i::GetTitleSize()
1201 //----------------------------------------------------------------------------
1202 CORBA::Long VISU::PointMap3d_i::GetLabelSize()
1207 //----------------------------------------------------------------------------
1208 CORBA::Long VISU::PointMap3d_i::GetBarWidth()
1213 //----------------------------------------------------------------------------
1214 CORBA::Long VISU::PointMap3d_i::GetBarHeight()
1219 //----------------------------------------------------------------------------
1221 VISU::PointMap3d_i::SetLabelsFormat(const char* theFormat)
1223 if( myLabelsFormat != theFormat ){
1224 myLabelsFormat = theFormat;
1225 myParamsTime.Modified();
1229 //----------------------------------------------------------------------------
1230 char* VISU::PointMap3d_i::GetLabelsFormat()
1232 return CORBA::string_dup(myLabelsFormat.c_str());
1235 //----------------------------------------------------------------------------
1236 void VISU::PointMap3d_i::SetUnitsVisible(CORBA::Boolean isVisible)
1238 if( myIsUnits != isVisible ){
1239 myIsUnits = isVisible;
1240 myParamsTime.Modified();
1244 //----------------------------------------------------------------------------
1245 CORBA::Boolean VISU::PointMap3d_i::IsUnitsVisible()
1250 //----------------------------------------------------------------------------
1251 void VISU::PointMap3d_i::SetRatios(CORBA::Long theTitleSize,
1252 CORBA::Long theLabelSize,
1253 CORBA::Long theBarWidth, CORBA::Long theBarHeight)
1255 bool anIsSameValue = VISU::CheckIsSameValue(myTitleSize, theTitleSize);
1256 anIsSameValue &= VISU::CheckIsSameValue(myLabelSize, theLabelSize);
1257 anIsSameValue &= VISU::CheckIsSameValue(myBarWidth, theBarWidth);
1258 anIsSameValue &= VISU::CheckIsSameValue(myBarHeight, theBarHeight);
1262 myTitleSize = theTitleSize;
1263 myLabelSize = theLabelSize;
1264 myBarWidth = theBarWidth;
1265 myBarHeight = theBarHeight;
1266 myParamsTime.Modified();