Version: 9.16.0
EditionProc.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "EditionProc.hxx"
21
22#include "QtGuiContext.hxx"
23#include "LinkInfo.hxx"
24#include "Logger.hxx"
25#include <QComboBox>
26
27//#define _DEVDEBUG_
28#include "YacsTrace.hxx"
29
30#include <cassert>
31
32using namespace std;
33
34using namespace YACS;
35using namespace YACS::HMI;
36using namespace YACS::ENGINE;
37
38EditionProc::EditionProc(Subject* subject,
39 QWidget* parent,
40 const char* name)
41 : EditionBloc(subject, parent, name)
42{
43 DEBTRACE("EditionProc::EditionProc");
44 _statusLog = new QTextEdit(this);
45 _wid->gridLayout1->addWidget(_statusLog);
46 _errorLog = "";
47 _modifLog = "";
48
49 if (!QtGuiContext::getQtCurrent()->isEdition())
50 {
51 QHBoxLayout* hbox = new QHBoxLayout();
52 QLabel* la = new QLabel("Shutdown level:",this);
53 QComboBox* cb = new QComboBox(this);
54 cb->addItem("0",0 );
55 cb->addItem("1",1 );
56 cb->addItem("2",2 );
57 cb->addItem("3",3 );
58 int level=1;
59 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
61 DEBTRACE(level);
62 cb->setCurrentIndex(level);
63 connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(onLevelChange(int)));
64 hbox->addWidget(la);
65 hbox->addWidget(cb);
66 _wid->gridLayout1->addLayout(hbox,4,0);
67 }
68}
69
71{
72 DEBTRACE("EditionProc::~EditionProc");
73}
74
75void EditionProc::update(GuiEvent event, int type, Subject* son)
76{
77 DEBTRACE("EditionProc::update " << GuiObserver::eventName(event));
78 EditionBloc::update(event, type, son);
79 string statusLog = "";
80 switch (event)
81 {
82 case EDIT:
83 if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty())
84 _modifLog = "";
85 else
86 _modifLog = "--- some elements are modified and not taken into account. Confirmation or annulation required ---\n";
87 case UPDATE:
89 break;
90 case UPDATEPROGRESS:
91 {
92 if(type != YACS::FINISHED)break;
93 if (!QtGuiContext::getQtCurrent()) break;
94 if (!QtGuiContext::getQtCurrent()->getGuiExecutor()) break;
97 _statusLog->setText(QString::fromStdString(_errorLog));
98 break;
99 }
100 default:
101 ;
102 }
103
104}
105
107{
108 DEBTRACE("EditionProc::synchronize");
110 Logger* logger = 0;
111 string statusLog = "";
112
113 if (!QtGuiContext::getQtCurrent()->isEdition())
114 return;
115 if (!proc->isValid())
116 {
117 _errorLog = "--- YACS schema is not valid ---\n\n";
118 _errorLog += proc->getErrorReport();
120 }
121 else
122 {
123 // --- Check consistency
124 LinkInfo info(LinkInfo::ALL_DONT_STOP);
125 _errorLog="";
126 try
127 {
128 proc->checkConsistency(info);
129 if (info.areWarningsOrErrors())
130 _errorLog += info.getGlobalRepr();
131 else
132 {
133 _errorLog += "--- No Validity Errors ---\n";
134 _errorLog += "--- No Consistency Errors ---\n";
135 }
136 }
137 catch (Exception &ex)
138 {
139 _errorLog = "--- YACS schema has consistency errors ---\n\n";
140 _errorLog += ex.what();
141 }
143 }
144 // --- Add initial logger info
145 logger = proc->getLogger("parser");
146 if (!logger->isEmpty())
147 {
148 _errorLog += "--- Original file import log ---\n";
149 _errorLog += logger->getStr();
150 }
151 statusLog = _modifLog + _errorLog;
152 _statusLog->setText(statusLog.c_str());
153}
154
156{
157 DEBTRACE("EditionProc::onLevelChange " << index);
158 if (QtGuiContext::getQtCurrent()->getGuiExecutor())
160}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
WidEditItem * _wid
virtual std::string getErrorReport()
returns a string that contains an error report if the node is in error
void checkConsistency(LinkInfo &info) const
Class that deal with list of semantics links for high level analysis.
Definition: LinkInfo.hxx:83
std::string getGlobalRepr() const
Definition: LinkInfo.cxx:118
bool areWarningsOrErrors() const
Definition: LinkInfo.cxx:199
Class for logging error messages.
Definition: Logger.hxx:38
virtual bool isEmpty()
Definition: Logger.cxx:96
virtual std::string getStr()
Definition: Logger.cxx:85
virtual int isValid()
indicates if the node is valid (returns 1) or not (returns 0)
Definition: Node.cxx:730
Base class for all schema objects.
Definition: Proc.hxx:44
virtual Logger * getLogger(const std::string &name)
Definition: Proc.cxx:431
virtual void update(GuiEvent event, int type, Subject *son)
Definition: EditionBloc.cxx:44
virtual void update(GuiEvent event, int type, Subject *son)
Definition: EditionProc.cxx:75
virtual void synchronize()
virtual void onLevelChange(int index)
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
std::string getErrorReport(YACS::ENGINE::Node *node)
void setShutdownLevel(int level)
Definition: GuiExecutor.hxx:92
static std::string eventName(GuiEvent event)
static QtGuiContext * getQtCurrent()
YACS::HMI::GuiExecutor * getGuiExecutor()
@ FINISHED
Definition: define.hxx:70