--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : VisuGUI_InputPane.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VisuGUI_InputPane.h"
+
+#include "VisuGUI_Tools.h"
+
+#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_Result_i.hh"
+
+#include "SUIT_ResourceMgr.h"
+
+#include "SalomeApp_Module.h"
+
+#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+
+#include "SALOME_ListIO.hxx"
+
+#include "SALOMEDSClient_AttributeComment.hxx"
+#include "SALOMEDSClient_AttributeName.hxx"
+
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+
+using namespace VISU;
+
+VisuGUI_InputPane::VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* parent ) :
+ QGroupBox( 2, Qt::Horizontal, parent ),
+ myModule( theModule )
+{
+ //SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ setFrameStyle( QFrame::Box | QFrame::Sunken );
+
+ LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( myModule );
+ connect( aSelectionMgr, SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) );
+
+ new QLabel( "Med File : ", this );
+ myMedFile = new QLineEdit( this );
+ myMedFile->setReadOnly( true );
+ myMedFile->setEnabled( false );
+ myMedFile->setPaletteForegroundColor( Qt::black );
+
+ new QLabel( "Mesh : ", this );
+ myMeshName = new QLineEdit( this );
+ myMeshName->setReadOnly( true );
+ myMeshName->setEnabled( false );
+ myMeshName->setPaletteForegroundColor( Qt::black );
+
+ new QLabel( "Entity : ", this );
+ myEntityName = new QLineEdit( this );
+ myEntityName->setReadOnly( true );
+ myEntityName->setEnabled( false );
+ myEntityName->setPaletteForegroundColor( Qt::black );
+
+ new QLabel( "Field : ", this );
+ myFieldName = new QLineEdit( this );
+ myFieldName->setReadOnly( true );
+
+ new QLabel( "Time Stamp : ", this );
+ myTimeStamps = new QComboBox( this );
+
+ onSelectionChanged();
+
+ hide();
+}
+
+VisuGUI_InputPane::~VisuGUI_InputPane()
+{
+}
+
+bool VisuGUI_InputPane::check()
+{
+ return myTimeStamps->count() != 0;
+}
+
+void VisuGUI_InputPane::clear()
+{
+ myMedFile->clear();
+ myMeshName->clear();
+ myEntityName->clear();
+ myFieldName->clear();
+ myTimeStamps->clear();
+}
+
+void VisuGUI_InputPane::onSelectionChanged()
+{
+ clear();
+
+ SALOME_ListIO aListIO;
+ GetSelectionMgr( myModule )->selectedObjects(aListIO);
+
+ if (aListIO.Extent() != 1)
+ return;
+
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(myModule));
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+ if (!aSObject)
+ return;
+
+ VISU::Storable::TRestoringMap aMap;
+ _PTR(GenericAttribute) anAttr;
+ if (!aSObject->FindAttribute(anAttr, "AttributeComment"))
+ return;
+
+ _PTR(AttributeComment) aComment (anAttr);
+ string aComm = aComment->Value();
+ QString strIn (aComm.c_str());
+ VISU::Storable::StrToMap(strIn, aMap);
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+ if (aType == VISU::TFIELD)
+ {
+ _PTR(SObject) aMedObject = aSObject->GetFather()->GetFather()->GetFather();
+ if( !aMedObject )
+ return;
+
+ QString anEntityName, aTimeStampName;
+
+ _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
+ _PTR(ChildIterator) aIter = aCStudy->NewChildIterator(aSObject);
+ for( ; aIter->More(); aIter->Next() )
+ {
+ _PTR(SObject) aChildObj = aIter->Value();
+ if( !aChildObj )
+ return;
+
+ if( anEntityName.isNull() )
+ {
+ _PTR(SObject) aRefObj;
+ if( aChildObj->ReferencedObject( aRefObj ) )
+ anEntityName = aRefObj->GetName().c_str();
+ }
+
+ if( VISU::getValue(aChildObj, "myComment") == "TIMESTAMP" )
+ {
+ aTimeStampName = aChildObj->GetName().c_str();
+ myTimeStamps->insertItem( aTimeStampName );
+ }
+ }
+
+ myResult = FindResult( VISU::GetSObject( aSObject ).in() );
+
+ myEntity = VISU::getValue( aSObject, "myEntityId" ).toInt();
+
+ QString aMedFile = aMedObject->GetName().c_str();
+ QString aMeshName = VISU::getValue(aSObject, "myMeshName");
+ QString aFieldName = VISU::getValue(aSObject, "myName");
+
+ myMedFile->setText( aMedFile );
+ myMeshName->setText( aMeshName );
+ myEntityName->setText( anEntityName );
+ myFieldName->setText( aFieldName );
+ myTimeStamps->setCurrentItem( 0 );
+ }
+}
+
+void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs )
+{
+ clear();
+
+ CORBA::Long aTimeStampNumber = thePrs->GetTimeStampNumber();
+ VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = thePrs->GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+
+ for( int index = 0; index < aLength; index++ )
+ {
+ VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ index ];
+ QString aTime = anInfo.myTime.in();
+ myTimeStamps->insertItem( aTime );
+ }
+
+ myResult = thePrs->GetResultObject();
+ VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(GetServant(myResult).in());
+ myMedFile->setText( aResult->GetName().c_str() );
+
+ myEntity = (int)thePrs->GetEntity();
+
+ QString anEntityName;
+ switch( myEntity )
+ {
+ case NODE_ENTITY: anEntityName = "onNodes"; break;
+ case EDGE_ENTITY: anEntityName = "onEdges"; break;
+ case FACE_ENTITY: anEntityName = "onFaces"; break;
+ case CELL_ENTITY: anEntityName = "onCells"; break;
+ default: break;
+ }
+ myEntityName->setText( anEntityName );
+
+ myMeshName->setText( thePrs->GetMeshName() );
+ myFieldName->setText( thePrs->GetFieldName() );
+ myTimeStamps->setCurrentItem( thePrs->GetTimeStampIndexByNumber( aTimeStampNumber ) );
+}
+
+int VisuGUI_InputPane::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs )
+{
+ thePrs->SetResultObject( myResult );
+
+ thePrs->SetMeshName( myMeshName->text().latin1() );
+ thePrs->SetEntity( VISU::Entity( myEntity ) );
+ thePrs->SetFieldName( myFieldName->text().latin1() );
+ thePrs->SetTimeStampNumber( thePrs->GetTimeStampNumberByIndex( myTimeStamps->currentItem() ) );
+ return ( int )thePrs->Apply();
+}
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : VisuGUI_InputPane.h
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISUGUI_INPUTPANE_H
+#define VISUGUI_INPUTPANE_H
+
+#include "VISUConfig.hh"
+
+#include <qgroupbox.h>
+
+class QComboBox;
+class QLineEdit;
+
+class SalomeApp_Module;
+
+namespace VISU
+{
+ class ColoredPrs3d_i;
+ class Result_i;
+}
+
+class VisuGUI_InputPane : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* parent );
+ virtual ~VisuGUI_InputPane();
+
+public:
+ virtual bool check();
+ virtual void clear();
+
+ void initFromPrsObject( VISU::ColoredPrs3d_i* );
+ int storeToPrsObject( VISU::ColoredPrs3d_i* );
+
+public slots:
+ virtual void onSelectionChanged();
+
+private:
+ SalomeApp_Module* myModule;
+
+ QLineEdit* myMedFile;
+ QLineEdit* myMeshName;
+ QLineEdit* myEntityName;
+ QLineEdit* myFieldName;
+ QComboBox* myTimeStamps;
+
+ VISU::Result_var myResult;
+ int myEntity;
+};
+
+#endif
#include "VisuGUI_ScalarBarDlg.h"
+#include "VisuGUI_InputPane.h"
+
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
#include "VISU_ScalarMap_i.hh"
#include "VISU_ScalarMapAct.h"
+#include "VISU_Result_i.hh"
+
#include "LightApp_Application.h"
#include "SUIT_Session.h"
#include <qlayout.h>
#include <qvalidator.h>
#include <qcolordialog.h>
-
+#include <qtabwidget.h>
#include <vtkTextProperty.h>
using namespace std;
Constructor
*/
VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
- : QDialog(VISU::GetDesktop(theModule), 0, true,
+ : QDialog(VISU::GetDesktop(theModule), 0, false,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{
setName("VisuGUI_ScalarBarDlg");
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
+ myTabBox = new QTabWidget(this);
myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
- TopLayout->addWidget(myScalarPane);
+ myScalarPane->setMargin( 5 );
+ myInputPane = new VisuGUI_InputPane(theModule, this);
+ myTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
+
+ TopLayout->addWidget(myTabBox);
// Common buttons ===========================================================
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
}
}
+/*!
+ Initialize dialog from the presentation
+*/
+void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs)
+{
+ myScalarPane->initFromPrsObject( thePrs );
+
+ if( thePrs->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( thePrs );
+ myTabBox->showPage( myInputPane );
+ }
+
+ myTabBox->setCurrentPage( 0 );
+}
+
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs)
+{
+ int ok = 1;
+ if( !thePrs->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+
+ ok = myInputPane->storeToPrsObject( thePrs );
+ }
+
+ return ok && myScalarPane->storeToPrsObject(thePrs);
+}
+
/*!
Provides help on F1 button click
*/