// Module : SUPERV
using namespace std;
+
+#include "SALOMEDSClient.hxx"
+#include "SALOMEDS_SObject.hxx"
+#include "SALOMEDS_Study.hxx"
+#include <boost/shared_ptr.hpp>
+using namespace boost;
+
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SalomeApp_Study.h"
+#include "SUIT_Session.h"
+
+#include "SALOME_ListIO.hxx"
+
#include "SUPERVGUI_BrowseNodeDlg.h"
-#include "SUPERVGUI_Node.h"
#include "SUPERVGUI_CanvasNode.h"
-#include "SUPERVGUI_Port.h"
#include "SUPERVGUI_CanvasPort.h"
#include "SUPERVGUI.h"
+
#include <qlayout.h>
#include <qlabel.h>
#include <qlineedit.h>
if ( !myIsEditable ) return false;
QString aTxt = myValue->text();
- if ( aTxt.isNull() || aTxt.isEmpty() ) return false;
+ //mkr : fix for bug IPAL9441
+ //if ( aTxt.isNull() || aTxt.isEmpty() ) return false;
if ( aTxt.find( "Unknown" ) < 0 ) {
- return myPort->Input( Supervision.getEngine()->StringValue( aTxt ) );
+ SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+ if ( !aSupMod ) {
+ MESSAGE("NULL Supervision module!");
+ return false;
+ }
+ return myPort->Input( aSupMod->getEngine()->StringValue( aTxt ) );
}
return false;
}
}
-/**
- * Constructor (SUPERVGUI_Node)
- */
-SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode )
- : QDialog( theNode, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
-{
- myNode = theNode;
- myNodeCanvas = 0;
-
- init();
-}
-
/**
* Constructor (SUPERVGUI_CanvasNode)
*/
SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode )
- : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
+ : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
{
- myNode = 0;
myNodeCanvas = theNode;
init();
setSizeGripEnabled( true );
myPortsList.setAutoDelete( true );
- SUPERV_CNode aEngine;
- if (myNode != 0)
- aEngine = myNode->getEngine();
- else
- aEngine = myNodeCanvas->getEngine();
+ SUPERV_CNode aEngine = myNodeCanvas->getEngine();
- mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() );
-// mySelection->ClearIObjects();
-
setName( "SUPERVGUI_BrowseNodeDlg" );
setCaption( tr( "TIT_BROWSENODE" ) + aEngine->Name() );
if ( ports[i]->IsInput() ) {
if ( !ports[i]->IsGate() ) { // not a gate
SUPERVGUI_PortField* aField = new SUPERVGUI_PortField( aInBox, ports[i] );
- if ( aField->isEditable() ) myIsEditable = true;
+ if ( aField->isEditable() )
+ myIsEditable = true;
myPortsList.append( aField );
if ( !myActiveField )
myActiveField = aField;
if ( !myIsEditable )
aBtnLayout->addStretch();
- connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
- if (myNode != 0)
- myNode->getMain()->lockedGraph(true);
- else
- myNodeCanvas->getMain()->lockedGraph(true);
+ SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+ if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+ else MESSAGE("NULL Supervision module!");
+
+ myNodeCanvas->getMain()->lockedGraph(true);
}
/**
* Set inputed values of editable ports and then closes and destroys dialog
*/
void SUPERVGUI_BrowseNodeDlg::accept() {
+ myNodeCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
if ( myIsEditable ) {
SUPERVGUI_PortField* aField;
for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) {
aField->setNewValue();
}
- if (myNode != 0)
- myNode->sync();
- else {
- myNodeCanvas->sync();
- myNodeCanvas->getMain()->getCanvas()->update();
- }
+ myNodeCanvas->sync();
+ myNodeCanvas->getMain()->getCanvas()->update();
}
- if (myNode != 0)
- myNode->getMain()->lockedGraph(false);
- else
- myNodeCanvas->getMain()->lockedGraph(false);
+ myNodeCanvas->getMain()->lockedGraph(false);
QDialog::accept();
close();
}
* Closes and destroys dialog
*/
void SUPERVGUI_BrowseNodeDlg::reject() {
- if (myNode != 0)
- myNode->getMain()->lockedGraph(false);
- else
- myNodeCanvas->getMain()->lockedGraph(false);
+ myNodeCanvas->getMain()->lockedGraph(false);
QDialog::reject();
close();
}
void SUPERVGUI_BrowseNodeDlg::onSelectionChanged()
{
if ( myActiveField ) {
- if( mySelection->IObjectCount() == 1 ) {
- Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
+
+ SALOME_ListIO aList;
+ aList.Clear();
+
+ SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+ if ( !aSupMod ) {
+ MESSAGE("NULL Supervision module!");
+ return;
+ }
+
+ (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))
+ ->selectionMgr()->selectedObjects( aList );
+
+ if( aList.Extent() == 1 ) {
+ Handle( SALOME_InteractiveObject ) anIO = aList.First();
if ( anIO->hasEntry() ) {
- SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
- getStudyDocument()->FindObjectID( anIO->getEntry() );
+ _PTR(SObject) aObj ( dynamic_cast<SalomeApp_Study*>( aSupMod->getActiveStudy() )->
+ studyDS()->FindObjectID( anIO->getEntry() ) );
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- Standard_CString ior = "";
+ _PTR(GenericAttribute) anAttr;
+ QString ior("");
if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
- anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
- ior = anIOR->Value();
+ _PTR(AttributeIOR) anIOR ( anAttr );
+ ior = anIOR->Value().c_str();
}
else {
- ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
+ SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aObj->GetStudy().get() );
+ SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aObj.get() );
+ if ( aSStudy && aSSObj )
+ ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
}
myActiveField->setData( ior );
}
}
}
-/**
- * Constructor (SUPERVGUI_PortIn)
- */
-SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortIn* thePort )
- : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
-{
- myPort = thePort;
- myPortESNode = 0;
- myPortCanvas = 0;
-
- init();
-}
-
-/**
- * Constructor (SUPERVGUI_PortInESNode)
- */
-SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort )
- : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
-{
- myPort = 0;
- myPortESNode = thePort;
- myPortCanvas = 0;
-
- init();
-}
/**
* Constructor (SUPERVGUI_CanvasPort)
*/
SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort )
- : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
+ : QDialog( SUIT_Session::session()->activeApplication()->desktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
{
- myPort = 0;
- myPortESNode = 0;
myPortCanvas = thePort;
init();
myOKBtn = 0;
setSizeGripEnabled( true );
- mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() );
-// mySelection->ClearIObjects();
-
setName( "SUPERVGUI_GetValueDlg" );
setCaption( tr( "TIT_SETVALUE_PORT" ) );
QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox );
QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt );
aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 );
- SUPERV_Port aEngine;
- if (myPort != 0)
- aEngine = myPort->getPort();
- else if (myPortESNode != 0)
- aEngine = myPortESNode->getPort();
- else {
- aEngine = myPortCanvas->getEngine();
- }
+ SUPERV_Port aEngine = myPortCanvas->getEngine();
+
myField = new SUPERVGUI_PortField( aBox, aEngine );
bool myIsEditable = myField->isEditable();
aBoxLayout->addWidget( myField->myLabel, 1, 0 );
aBtnLayout->addStretch();
myField->updateGUI();
- connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
- if (myPort != 0)
- myPort->getMain()->lockedGraph(true);
- else if (myPortESNode != 0)
- myPortESNode->getMain()->lockedGraph(true);
- else
- myPortCanvas->getMain()->lockedGraph(true);
+
+ SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+ if ( aSupMod ) connect( (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+ else MESSAGE("NULL Supervision module!");
+
+ myPortCanvas->getMain()->lockedGraph(true);
}
/**
* Set entered value into port and then closes and destroys dialog
*/
void SUPERVGUI_GetValueDlg::accept() {
+ myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
if ( myField->setNewValue() ) {
- if (myPort != 0)
- myPort->sync();
- else if (myPortESNode != 0)
- myPortESNode->sync();
- else {
- myPortCanvas->sync();
+ myPortCanvas->sync();
- // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status
- if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) {
- SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent();
- aNode->sync();
- }
+ // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status
+ // asv : 13.12.04 : commented out sync() of Node. See 2.21.
+ //if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) {
+ // SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent();
+ // aNode->sync();
+ //}
- myPortCanvas->getMain()->getCanvas()->update();
- }
+ myPortCanvas->getMain()->getCanvas()->update();
}
else {
- if ( QMessageBox::warning( QAD_Application::getDesktop(),
+ if ( QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(),
tr( "ERROR" ), tr( "MSG_CANT_SETVAL" ),
QMessageBox::Retry, QMessageBox::Abort) == QMessageBox::Retry )
return;
}
- if (myPort != 0)
- myPort->getMain()->lockedGraph(false);
- else if (myPortESNode != 0)
- myPortESNode->getMain()->lockedGraph(false);
- else
- myPortCanvas->getMain()->lockedGraph(false);
+ myPortCanvas->getMain()->lockedGraph(false);
+
QDialog::accept();
close();
}
* Closes and destroys dialog
*/
void SUPERVGUI_GetValueDlg::reject() {
- if (myPort != 0)
- myPort->getMain()->lockedGraph(false);
- else if (myPortESNode != 0)
- myPortESNode->getMain()->lockedGraph(false);
- else
- myPortCanvas->getMain()->lockedGraph(false);
+ myPortCanvas->getMain()->lockedGraph(false);
QDialog::reject();
close();
}
*/
void SUPERVGUI_GetValueDlg::onSelectionChanged()
{
- if( mySelection->IObjectCount() == 1 ) {
- Handle( SALOME_InteractiveObject ) anIO = mySelection->firstIObject();
+ SALOME_ListIO aList;
+ aList.Clear();
+
+ SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+ if ( !aSupMod ) {
+ MESSAGE("NULL Supervision module!");
+ return;
+ }
+
+ (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application()))
+ ->selectionMgr()->selectedObjects( aList );
+
+ if( aList.Extent() == 1 ) {
+ Handle( SALOME_InteractiveObject ) anIO = aList.First();
if ( anIO->hasEntry() ) {
- SALOMEDS::SObject_var aObj = Supervision.getActiveStudy()->
- getStudyDocument()->FindObjectID( anIO->getEntry() );
+ _PTR(SObject) aObj ( dynamic_cast<SalomeApp_Study*>( aSupMod->getActiveStudy() )->
+ studyDS()->FindObjectID( anIO->getEntry() ) );
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- Standard_CString ior = "";
+ _PTR(GenericAttribute) anAttr;
+ QString ior("");
if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) {
- anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
- ior = anIOR->Value();
+ _PTR(AttributeIOR) anIOR ( anAttr );
+ ior = anIOR->Value().c_str();
}
else {
- ior = aObj->GetStudy()->ConvertObjectToIOR( aObj );
+ SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aObj->GetStudy().get() );
+ SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aObj.get() );
+ if ( aSStudy && aSSObj )
+ ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
}
myField->setData( ior );
}
// Stream Ports
// ----------------------------
-SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort)
- :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- myPort = thePort;
- myPortCanvas = 0;
- init();
-}
-
SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort)
- :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+ :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
- myPort = 0;
myPortCanvas = thePort;
init();
}
SUPERV::KindOfInterpolation aInterpolat;
SUPERV::KindOfExtrapolation aExtrapolat;
- if (myPort != 0)
- myPort->getStreamPort()->Params(aSchema, aInterpolat, aExtrapolat);
- else
- myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat);
+ myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat);
mySchemaCombo->setCurrentItem((int)aSchema);
myInterCombo->setCurrentItem((int)aInterpolat);
}
void SUPERVGUI_StreamInDlg::accept() {
- if (myPort != 0)
- myPort->getStreamPort()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(),
- (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
- (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
- else
- myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(),
- (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
- (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
+ myPortCanvas->getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag
+ myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(),
+ (SUPERV::KindOfInterpolation) myInterCombo->currentItem(),
+ (SUPERV::KindOfExtrapolation) myExterCombo->currentItem());
QDialog::accept();
}
//-------------------------------------------------------------------------
-SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort)
- :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- myPort = thePort;
- myPortCanvas = 0;
- init();
-}
SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort)
- :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+ :QDialog( SUIT_Session::session()->activeApplication()->desktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
- myPort = 0;
myPortCanvas = thePort;
init();
}
myValEdit = new QLineEdit( aCtrlPane, "ValEdit" );
myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myValEdit->setValidator( new QIntValidator(this) );
- SUPERV_StreamPort aEngine;
- if (myPort != 0)
- aEngine = myPort->getStreamPort();
- else
- aEngine = myPortCanvas->getStreamEngine();
+ SUPERV_StreamPort aEngine = myPortCanvas->getStreamEngine();
myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues()));
aCtrlLayout->addWidget(myValEdit, 0, 1);
TopLayout->addWidget( aCtrlPane );
QString aStr = myValEdit->text();
if (!aStr.isEmpty())
aRes = aStr.toLong();
- if (myPort != 0)
- myPort->getStreamPort()->SetNumberOfValues(aRes);
- else
- myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes);
+ myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes);
QDialog::accept();
}