From 7a7b1775387967609b530c5a37a609a5173b4862 Mon Sep 17 00:00:00 2001 From: smh Date: Thu, 6 May 2004 14:12:24 +0000 Subject: [PATCH] StreamPorts Dialog boxes --- src/SUPERVGUI/SUPERVGUI_Link.cxx | 4 - src/SUPERVGUI/SUPERVGUI_Port.cxx | 242 ++++++++++++++++++++++++++++--- src/SUPERVGUI/SUPERVGUI_Port.h | 54 ++++++- src/SUPERVGUI/SUPERV_msg_en.po | 21 +++ 4 files changed, 291 insertions(+), 30 deletions(-) diff --git a/src/SUPERVGUI/SUPERVGUI_Link.cxx b/src/SUPERVGUI/SUPERVGUI_Link.cxx index 88b0a53..5787cac 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Link.cxx @@ -402,10 +402,6 @@ bool SUPERVGUI_Link::isCreationComplete() { QString aInNodeName(aInPort->Node()->Name()); SUPERV_Port aOutPort = myPortOut->getPort(); QString aOutNodeName(aOutPort->Node()->Name()); - cout<<"### OutNode = "< +#include #include "SUPERVGUI_GraphNode.h" @@ -81,6 +82,8 @@ SUPERVGUI_Port::SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ ( port->IsEndSwitch() && port->IsInput())) { myDelItem = popup->insertItem(tr("ITM_DEL_PORT"), this, SLOT(deletePort())); } + browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); + connect(this, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); connect(this, SIGNAL(MouseRelease(QMouseEvent*)), this, SLOT(endSketch())); } @@ -99,7 +102,7 @@ void SUPERVGUI_Port::showPopup(QMouseEvent* e) { if (e->button() != RightButton) return; if (main->getDataflow()->IsExecuting()) popup->setItemEnabled(mySketchItem, false); - else + /* else if (!port->IsInput() //output port || port->IsInput() && (!port->IsLinked() //not linked input port @@ -107,11 +110,19 @@ void SUPERVGUI_Port::showPopup(QMouseEvent* e) { port->Kind() == SUPERV::EndSwitchParameter)) { //input port of EndSwitch node popup->setItemEnabled(mySketchItem, true); } - + */ main->showPopup(popup, e); } +void SUPERVGUI_Port::browse() { + Trace("SUPERVGUI_Port::browse") + QString mess = (port->IsInput())? (tr("MSG_IPORT_VAL")) : (tr("MSG_OPORT_VAL")); + mess += port->ToString(); + QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); +} + + QPoint SUPERVGUI_Port::getConnectPnt() { return QPoint(0,0); } @@ -166,7 +177,7 @@ SUPERVGUI_PortIn::SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::P if ((!port->IsGate()) && editing ) { psc = popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput())); } - browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + // browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); } SUPERVGUI_PortIn::~SUPERVGUI_PortIn() { @@ -181,6 +192,16 @@ bool SUPERVGUI_PortIn::eventFilter( QObject* o, QEvent* e ) return SUPERVGUI_Port::eventFilter( o, e ); } +void SUPERVGUI_PortIn::showPopup(QMouseEvent* e){ + if (e->button() != RightButton) return; + if (main->getDataflow()->IsExecuting()) + popup->setItemEnabled(mySketchItem, false); + else { + popup->setItemEnabled(mySketchItem, !port->IsLinked()); + popup->setItemEnabled(psc, !port->IsLinked()); + } + main->showPopup(popup, e); +} void SUPERVGUI_PortIn::deleteLinks() { if (myLinkPrs) { @@ -193,14 +214,15 @@ void SUPERVGUI_PortIn::deleteLinks() { void SUPERVGUI_PortIn::sync() { SUPERVGUI_Port::sync(); - if (port->IsLinked()) { - popup->setItemEnabled(browser, port->State() == SUPERV_Ready); - } else { + // if (port->IsLinked()) { + // popup->setItemEnabled(browser, port->State() == SUPERV_Ready); + //} else { + if (!port->IsLinked()) { if (port->HasInput()) { - popup->setItemEnabled(browser, true); + // popup->setItemEnabled(browser, true); setLineWidth(2); } else { - popup->setItemEnabled(browser, false); + //popup->setItemEnabled(browser, false); setLineWidth(1); } } @@ -230,12 +252,12 @@ void SUPERVGUI_PortIn::setInput() { } } -void SUPERVGUI_PortIn::browse() { +/*void SUPERVGUI_PortIn::browse() { Trace("SUPERVGUI_PortIn::browse") QString mess(tr("MSG_IPORT_VAL")); mess += port->ToString(); QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); -} + }*/ @@ -295,7 +317,7 @@ SUPERVGUI_PortOut::SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV: if (!port->IsGate()) { pls = popup->insertItem(tr("MSG_PUT_INSTUDY"), this, SLOT(toStudy())); } - browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + //browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); if (!main->getDataflow()->IsReadOnly()) { popup->setItemEnabled(mySketchItem, true); @@ -313,7 +335,7 @@ void SUPERVGUI_PortOut::sync() { SUPERVGUI_Port::sync(); bool ok = (port->State() == SUPERV_Ready); - popup->setItemEnabled(browser, ok); + // popup->setItemEnabled(browser, ok); if (study && ok) { study = main->putDataStudy(port, STUDY_PORT_OUT); } @@ -356,12 +378,12 @@ void SUPERVGUI_PortOut::toStudy() { sync(); } -void SUPERVGUI_PortOut::browse() { +/*void SUPERVGUI_PortOut::browse() { Trace("SUPERVGUI_PortOut::browse") QString mess(tr("MSG_OPORT_VAL")); mess += port->ToString(); QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); -} + }*/ /** @@ -422,7 +444,7 @@ SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* if ((!port->IsGate()) && editing ) { psc = popup->insertItem(tr("MSG_SETVALUE"),this, SLOT(setInput())); } - browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); + // browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); } SUPERVGUI_PortInESNode::~SUPERVGUI_PortInESNode() { @@ -437,14 +459,15 @@ bool SUPERVGUI_PortInESNode::eventFilter( QObject* o, QEvent* e ) { void SUPERVGUI_PortInESNode::sync() { SUPERVGUI_Port::sync(); - if (port->IsLinked()) { + /* if (port->IsLinked()) { popup->setItemEnabled(browser, port->State() == SUPERV_Ready); - } else { + } else {*/ + if (!port->IsLinked()) { if (port->HasInput()) { - popup->setItemEnabled(browser, true); + // popup->setItemEnabled(browser, true); setLineWidth(2); } else { - popup->setItemEnabled(browser, false); + // popup->setItemEnabled(browser, false); setLineWidth(1); } } @@ -508,12 +531,12 @@ void SUPERVGUI_PortInESNode::setInput() { } } -void SUPERVGUI_PortInESNode::browse() { +/*void SUPERVGUI_PortInESNode::browse() { Trace("SUPERVGUI_PortInESNode::browse") QString mess(tr("MSG_IPORT_VAL")); mess += port->ToString(); QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); -} + }*/ void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { @@ -541,37 +564,212 @@ void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { // ---------------------------- // Stream Ports // ---------------------------- +SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = thePort; + setSizeGripEnabled( true ); + setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); + + QFrame* aCtrlPane = new QFrame(this); + QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); + + // Schema + QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane); + aCtrlLayout->addWidget(aSchemaLbl, 0, 0); + + mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" ); + mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + mySchemaCombo->insertItem("SCHENULL"); + mySchemaCombo->insertItem("TI"); + mySchemaCombo->insertItem("TF"); + mySchemaCombo->insertItem("DELTA"); + aCtrlLayout->addWidget(mySchemaCombo, 0, 1); + + // Interpolation + QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane); + aCtrlLayout->addWidget(aInterLbl, 1, 0); + + myInterCombo = new QComboBox(aCtrlPane, "InterBox" ); + myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myInterCombo->insertItem("INTERNULL"); + myInterCombo->insertItem("L0"); + myInterCombo->insertItem("L1"); + aCtrlLayout->addWidget(myInterCombo, 1, 1); + + // Extrapolation + QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane); + aCtrlLayout->addWidget(aExtraLbl, 2, 0); + + myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" ); + myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myExterCombo->insertItem("EXTRANULL"); + myExterCombo->insertItem("E0"); + myExterCombo->insertItem("E1"); + aCtrlLayout->addWidget(myExterCombo, 2, 1); + + TopLayout->addWidget( aCtrlPane ); + + // Buttons + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 5 ); + GroupButtonsLayout->setMargin( 8 ); + + QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); + + GroupButtonsLayout->addWidget( okB, 0, 0 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + + TopLayout->addWidget( GroupButtons ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); + setData(); +} + + +void SUPERVGUI_StreamInDlg::setData() { + SUPERV::KindOfSchema aSchema; + SUPERV::KindOfInterpolation aInterpolat; + SUPERV::KindOfExtrapolation aExtrapolat; + + myPort->getStreamPort()->Params(aSchema, aInterpolat, aExtrapolat); + + mySchemaCombo->setCurrentItem((int)aSchema); + myInterCombo->setCurrentItem((int)aInterpolat); + myExterCombo->setCurrentItem((int)aExtrapolat); +} + + + +void SUPERVGUI_StreamInDlg::accept() { + myPort->getStreamPort()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), + (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), + (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); + QDialog::accept(); +} + +//--------------------------------------------------------------------------------------- + + SUPERVGUI_StreamPortIn::SUPERVGUI_StreamPortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p): SUPERVGUI_PortIn(parent, m, p) { myPort = SUPERV::StreamPort::_duplicate(p); - + myParamItem = popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); } SUPERVGUI_StreamPortIn::~SUPERVGUI_StreamPortIn() { } + +void SUPERVGUI_StreamPortIn::setParams() +{ + SUPERVGUI_StreamInDlg* aDlg = new SUPERVGUI_StreamInDlg(this); + aDlg->exec(); + delete aDlg; +} + + void SUPERVGUI_StreamPortIn::sync() { SUPERVGUI_PortIn::sync(); setText(myName + "=" + myPort->ToString()); } +//------------------------------------------------------------------------- + +SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = thePort; + setSizeGripEnabled( true ); + setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); + QFrame* aCtrlPane = new QFrame(this); + QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); + + QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane); + aCtrlLayout->addWidget(aLbl, 0, 0); + + myValEdit = new QLineEdit( aCtrlPane, "ValEdit" ); + myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myValEdit->setValidator( new QIntValidator(this) ); + myValEdit->setText(QString("%1").arg(myPort->getStreamPort()->NumberOfValues())); + aCtrlLayout->addWidget(myValEdit, 0, 1); + TopLayout->addWidget( aCtrlPane ); + + // Buttons + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 5 ); + GroupButtonsLayout->setMargin( 8 ); + + QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); + + GroupButtonsLayout->addWidget( okB, 0, 0 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + + TopLayout->addWidget( GroupButtons ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +void SUPERVGUI_StreamOutDlg::accept() { + int aRes = 0; + QString aStr = myValEdit->text(); + if (!aStr.isEmpty()) + aRes = aStr.toLong(); + myPort->getStreamPort()->SetNumberOfValues(aRes); + QDialog::accept(); +} + + +//------------------------------------------------------------------------------------------------ SUPERVGUI_StreamPortOut::SUPERVGUI_StreamPortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p): SUPERVGUI_PortOut(parent, m, p) { myPort = SUPERV::StreamPort::_duplicate(p); + myParamItem = popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); } SUPERVGUI_StreamPortOut::~SUPERVGUI_StreamPortOut() { } +void SUPERVGUI_StreamPortOut::setParams() +{ + SUPERVGUI_StreamOutDlg* aDlg = new SUPERVGUI_StreamOutDlg(this); + aDlg->exec(); + delete aDlg; +} + + void SUPERVGUI_StreamPortOut::sync() { SUPERVGUI_PortOut::sync(); setText(myName + "=" + myPort->ToString()); } + + +//------------------------------------------------------------------------------------------------ diff --git a/src/SUPERVGUI/SUPERVGUI_Port.h b/src/SUPERVGUI/SUPERVGUI_Port.h index d8146d8..8137e35 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.h +++ b/src/SUPERVGUI/SUPERVGUI_Port.h @@ -56,6 +56,7 @@ class SUPERVGUI_Port: public SUPERVGUI_Label { void endSketch(); protected slots: + void browse(); virtual void deletePort(); protected: @@ -72,7 +73,7 @@ class SUPERVGUI_Port: public SUPERVGUI_Label { QString myName; private slots: - void showPopup(QMouseEvent* e); + virtual void showPopup(QMouseEvent* e); }; @@ -101,8 +102,9 @@ class SUPERVGUI_PortIn: public SUPERVGUI_Port { private slots: void setInput(); - void browse(); + // void browse(); void onDeleteLink(SUPERVGUI_Link*); + virtual void showPopup(QMouseEvent* e); private: @@ -141,7 +143,7 @@ class SUPERVGUI_PortOut: public SUPERVGUI_Port { private slots: void toStudy(); - void browse(); + // void browse(); void sketch(QMouseEvent* e); void onDeleteLink(SUPERVGUI_Link*); @@ -180,7 +182,7 @@ class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { private slots: void setInput(); - void browse(); + // void browse(); void onDeleteLink(SUPERVGUI_Link*); @@ -199,6 +201,25 @@ class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { //**************************************************************** +class SUPERVGUI_StreamPortIn; +class SUPERVGUI_StreamInDlg: public QDialog +{ + Q_OBJECT +public: + SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort); + virtual ~SUPERVGUI_StreamInDlg() {}; + +protected slots: + void accept(); + +private: + void setData(); + + SUPERVGUI_StreamPortIn* myPort; + QComboBox* mySchemaCombo; + QComboBox* myInterCombo; + QComboBox* myExterCombo; +}; class SUPERVGUI_StreamPortIn: public SUPERVGUI_PortIn { @@ -210,12 +231,33 @@ public: void sync(); SUPERV_StreamPort getStreamPort() { return myPort;} +private slots: + void setParams(); + private: SUPERV_StreamPort myPort; + + int myParamItem; }; //************************************************************** +class SUPERVGUI_StreamPortOut; +class SUPERVGUI_StreamOutDlg: public QDialog +{ + Q_OBJECT +public: + SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort); + virtual ~SUPERVGUI_StreamOutDlg() {}; + +protected slots: + void accept(); + +private: + SUPERVGUI_StreamPortOut* myPort; + QLineEdit* myValEdit; +}; + class SUPERVGUI_StreamPortOut: public SUPERVGUI_PortOut { Q_OBJECT @@ -226,8 +268,12 @@ public: void sync(); SUPERV_StreamPort getStreamPort() { return myPort;} +private slots: + void setParams(); + private: SUPERV_StreamPort myPort; + int myParamItem; }; diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index 200e43a..fe81a57 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -336,6 +336,27 @@ msgstr "Set Value" msgid "MSG_BROWSE" msgstr "Browse" +msgid "MSG_STREAM_PARAM" +msgstr "Parameters..." + +msgid "MSG_STREAM_DLG_TIT" +msgstr "Stream Port Parameters" + +msgid "MSG_STREAM_DLG_TIT" +msgstr "Stream Port Parameters" + +msgid "MSG_STREAM_SCHEMA" +msgstr "Schema" + +msgid "MSG_STREAM_INTER" +msgstr "Interpolation" + +msgid "MSG_STREAM_EXTRA" +msgstr "Extrapolation" + +msgid "MSG_STREAM_LEVEL" +msgstr "Level" + msgid "MSG_DELLINK" msgstr "Delete Link" -- 2.39.2