-// SUPERV SUPERVGUI : GUI for Supervisor 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
//
-// Copyright (C) 2003 OPEN CASCADE
+// SUPERV SUPERVGUI : GUI for Supervisor component
//
// File : SUPERVGUI_Ganvas.cxx
// Author : Natalia KOPNOVA
// Module : SUPERV
-using namespace std;
+#include "SUPERVGUI.h"
#include "SUPERVGUI_Def.h"
#include "SUPERVGUI_Main.h"
#include "SUPERVGUI_CanvasNode.h"
#include "SUPERVGUI_CanvasPort.h"
#include "SUPERVGUI_CanvasLink.h"
-#include "QAD_Config.h"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
//#define CHECKTIME
ihmList->removeRef(ihmNode); \
ihmNode->merge(); \
ihmNode = getNode(aCNodeEnd); \
- ihmList->removeRef(ihmNode); \
- ihmNode->merge(); \
+ if (ihmNode) { \
+ ihmList->removeRef(ihmNode); \
+ ihmNode->merge(); \
+ } \
} \
}
*/
-SUPERVGUI_Canvas::SUPERVGUI_Canvas(SUPERVGUI_Main* m):
+SUPERVGUI_Canvas::SUPERVGUI_Canvas( SUPERVGUI_Main* m, SUIT_ResourceMgr* mgr ):
QCanvas(),
myMain(m)
{
Trace("SUPERVGUI_Canvas::SUPERVGUI_Canvas");
myIsControlView = false;
// resize(GRAPH_WIDTH, GRAPH_HEIGHT);
- resize(800, 600);
+ resize(1050, 750);
setDoubleBuffering(true);
- QColor aColor(MAIN_COLOR);
- QString aRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
- QString aGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
- QString aBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
- if( (!aRed.isEmpty()) && (!aGreen.isEmpty()) && (!aBlue.isEmpty()) )
- aColor = QColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt());
+ // mkr : IPAL10825 -->
+ SUPERVGUI* aSupMod = SUPERVGUI::Supervision();
+ if ( !aSupMod ) {
+ MESSAGE("NULL Supervision module!");
+ return;
+ }
+ QColor aColor = aSupMod->getIVFBackgroundColor();
+ if ( !aColor.isValid() )
+ aColor = mgr->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR );
+ // <--
+
+ //aColor = QColor(SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorRed" ),
+ // SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorGreen" ),
+ // SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorBlue" ) );
setBackgroundColor(aColor);
}
SUPERVGUI_Canvas::~SUPERVGUI_Canvas() {
+ // asv : 17.01.05 : why delete its own children (CanvasNode-s)?
+ // they must be destroyed automatically.
QObjectList* aNodeList = queryList("SUPERVGUI_CanvasNode");
QObjectListIt aIt(*aNodeList);
QObject* anObj;
- while ((anObj = aIt.current()) != 0) {
+ while ( (anObj = aIt.current()) != 0 ) {
++aIt;
+ aNodeList->removeRef(anObj);
delete anObj;
}
+ // asv : list returned by queryList() must be removed
+ delete aNodeList;
}
void SUPERVGUI_Canvas::addView(QCanvasView* theView)
}
void SUPERVGUI_Canvas::sync() {
- // cout << "===> SUPERVGUI_Canvas::sync()" << endl;
if (SUPERV_isNull(myMain->getDataflow())) return;
SUPERVGUI_CanvasNode* ihmNode;
* Synchronizes Graph presentation with internal graph structure
*/
void SUPERVGUI_Canvas::merge() {
- // cout << "===> SUPERVGUI_Canvas::merge()" << endl;
if (SUPERV_isNull(myMain->getDataflow())) return;
-
+
SUPERVGUI_CanvasNode* ihmNode;
QObjectList* ihmList = queryList("SUPERVGUI_CanvasNode");
SUPERV_Nodes nodes = myMain->getDataflow()->Nodes();
MESSAGE("Graphs="<<nodes->Graphs.length());
int n;
- //cout << " update nodes " << endl;
UPDATENODES(CNodes, addComputeNode);
UPDATENODES(FNodes, addComputeNode);
UPDATENODES(INodes, addComputeNode);
UPDATENODES(Graphs, addMacroNode);
UPDATENODES(GNodes, addGOTONode);
- //cout << " update control nodes " << endl;
UPDATECONTROLNODES(LNodes);
UPDATECONTROLNODES(SNodes);
+ /*
+ n = nodes->LNodes.length();
+ for (int i=0; i<n; i++) {
+ SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->LNodes[i]);
+ SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->LNodes[i]->Coupled());
+ ihmNode = getNode(aCNode);
+ SUPERVGUI_CanvasNode* ihmNodeEnd = getNode(aCNodeEnd);
+ if (ihmNode == NULL) {
+ myMain->addControlNode(aCNode, aCNodeEnd, false);
+ } else {
+ if (ihmNodeEnd) {
+ ihmNode->move(aCNode->X(), aCNode->Y());
+ ihmList->removeRef(ihmNode);
+ ihmNode->merge();
+ ihmNode = getNode(aCNodeEnd);
+ ihmList->removeRef(ihmNode);
+ ihmNode->merge();
+ }
+ }
+ }
+ n = nodes->SNodes.length();
+ for (int i=0; i<n; i++) {
+ SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->SNodes[i]);
+ SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->SNodes[i]->Coupled());
+ ihmNode = getNode(aCNode);
+ if (ihmNode == NULL) {
+ myMain->addControlNode(aCNode, aCNodeEnd, false);
+ } else {
+ ihmNode->move(aCNode->X(), aCNode->Y());
+ ihmList->removeRef(ihmNode);
+ ihmNode->merge();
+ ihmNode = getNode(aCNodeEnd);
+ ihmList->removeRef(ihmNode);
+ ihmNode->merge();
+ }
+ }
+ //*/
QObjectListIt it(*ihmList);
while ((ihmNode=(SUPERVGUI_CanvasNode*)it.current()) != 0) {
delete ihmList;
// update links
- //cout << " update links " << endl;
SUPERVGUI_CanvasLink* ihmLink;
ihmList = queryList("SUPERVGUI_CanvasLink");
/*
*/
//SUPERV_Links links = myMain->getDataflow()->Links();
SUPERV_Links links = myMain->getDataflow()->GLinks();
- //cout << "===> Number of links " << links->length() << endl;
for (int i = 0; i < links->length(); i++) {
UPDATELINK(links[i]);
}
/*
SUPERV_StreamLinks slinks = myMain->getDataflow()->StreamLinks();
- //cout << "===> Number of stream links " << slinks->length() << endl;
for (int i = 0; i < slinks->length(); i++) {
UPDATELINK(slinks[i]);
}
SUPERV_StreamGraph aSGraph = myMain->getDataflow()->ToStreamGraph();
if (!SUPERV_isNull(aSGraph)) {
SUPERV_StreamLinks slinks = aSGraph->StreamLinks(); // <<- doesn't work!!!
- //cout << "===> Number of stream links " << slinks->length() << endl;
for (int i = 0; i < slinks->length(); i++) {
UPDATELINK(slinks[i]);
}
delete ihmLink;
}
delete ihmList;
- //cout << " merge done " << endl;
-}
-
-void SUPERVGUI_Canvas::setAsFromStudy(bool theToStudy)
-{
- if (theToStudy) return;
-
- SUPERVGUI_CanvasPortOut* aPortOut;
- QObjectList* aPortList = queryList("SUPERVGUI_CanvasPortOut");
- QObjectListIt aPortIt(*aPortList);
- while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) {
- ++aPortIt;
- if (aPortOut->isInStudy()) {
- aPortOut->setStudyState(theToStudy);
- aPortOut->sync();
- }
- }
- delete aPortList;
}
SUPERVGUI_CanvasNode* SUPERVGUI_Canvas::getNode(SUPERV::CNode_ptr theNode) const