Skip to content

Commit 185f195

Browse files
committed
Merge branch 'gui_V3' into matlab2.2
2 parents c17c718 + 91ce37b commit 185f195

File tree

2 files changed

+61
-30
lines changed

2 files changed

+61
-30
lines changed

src/Interface/Application/NetworkEditor.cc

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ NetworkEditor::NetworkEditor(boost::shared_ptr<CurrentModuleSelection> moduleSel
9494
connect(scene_, SIGNAL(changed(const QList<QRectF>&)), this, SIGNAL(sceneChanged(const QList<QRectF>&)));
9595

9696
updateActions();
97-
ensureVisible(0,0,0,0);
97+
98+
setSceneRect(QRectF(-1000, -1000, 2000, 2000));
99+
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
100+
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
101+
centerOn(100, 100);
98102

99103
setMouseAsDragMode();
100104

@@ -353,6 +357,7 @@ void NetworkEditor::setupModuleWidget(ModuleWidget* module)
353357
proxy->highlightPorts(Preferences::Instance().highlightPorts ? 1 : 0);
354358

355359
scene_->addItem(proxy);
360+
ensureVisible(proxy);
356361
proxy->createStartupNote();
357362

358363
scene_->clearSelection();
@@ -815,7 +820,10 @@ void NetworkEditor::updateModulePositions(const ModulePositions& modulePositions
815820
{
816821
auto posIter = modulePositions.modulePositions.find(w->getModuleWidget()->getModuleId());
817822
if (posIter != modulePositions.modulePositions.end())
823+
{
818824
w->setPos(posIter->second.first, posIter->second.second);
825+
ensureVisible(w);
826+
}
819827
}
820828
}
821829
}
@@ -925,6 +933,8 @@ void NetworkEditor::loadNetwork(const SCIRun::Dataflow::Networks::NetworkFileHan
925933
//TODO: duplication
926934
const std::string value = Application::Instance().parameters()->entireCommandLine().find("--testUpdateThread") != std::string::npos ? "yes" : "no";
927935
controller_->getSettings().setValue("networkStateUpdateThread", value);
936+
937+
setSceneRect(QRectF());
928938
}
929939

930940
size_t NetworkEditor::numModules() const
@@ -1261,8 +1271,11 @@ void NetworkEditor::displayError(const QString& msg, std::function<void()> showM
12611271
scene()->addItem(errorItem);
12621272

12631273
QPointF tl(horizontalScrollBar()->value(), verticalScrollBar()->value());
1274+
//qDebug() << "tl" << tl;
12641275
QPointF br = tl + viewport()->rect().bottomRight();
1276+
//qDebug() << "br" << br;
12651277
QMatrix mat = matrix().inverted();
1278+
//qDebug() << "mat" << mat;
12661279
auto rect = mat.mapRect(QRectF(tl,br));
12671280

12681281
//auto rectOld = mapToScene(viewport()->geometry()).boundingRect();
@@ -1272,7 +1285,22 @@ void NetworkEditor::displayError(const QString& msg, std::function<void()> showM
12721285
auto corner = rect.bottomLeft();
12731286
//qDebug() << corner;
12741287

1275-
errorItem->setPos(corner + QPointF(-300, -(40*errorItem->num() + 200)));
1288+
errorItem->setPos(corner + QPointF(100, -(40*errorItem->num() + 100)));
1289+
1290+
#if 0
1291+
auto xMin = rect.topLeft().x();
1292+
auto xMax = rect.topRight().x();
1293+
auto yMin = rect.topLeft().y();
1294+
auto yMax = rect.bottomLeft().y();
1295+
for (double x = xMin; x < xMax; x += 100)
1296+
for (double y = yMin; y < yMax; y += 100)
1297+
{
1298+
QString xy = QString::number(x) + "," + QString::number(y);
1299+
auto item = scene()->addText(xy);
1300+
item->setDefaultTextColor(Qt::white);
1301+
item->setPos(x, y);
1302+
}
1303+
#endif
12761304
}
12771305

12781306
NetworkEditor::~NetworkEditor()

src/Modules/Legacy/Matlab/Interface/InterfaceWithMatlab.cc

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -887,12 +887,12 @@ bool InterfaceWithMatlabImpl::open_matlab_engine()
887887

888888
if (!engOpen || !engClose || !engSetVisible || !engEvalString || !engOutputBuffer)
889889
{
890-
if (!engOpen) module_->error(std::string("Cannot find engOpen"));
891-
if (!engClose) module_->error(std::string("Cannot find engClose"));
892-
if (!engSetVisible) module_->error(std::string("Cannot find engSetVisible"));
893-
if (!engEvalString) module_->error(std::string("Cannot find engEvalString"));
894-
if (!engOutputBuffer) module_->error(std::string("Cannot find engOutputBuffer"));
895-
module_->error(std::string("Could not open matlab engine functions from matlab library"));
890+
if (!engOpen) module_->error("Cannot find engOpen");
891+
if (!engClose) module_->error("Cannot find engClose");
892+
if (!engSetVisible) module_->error("Cannot find engSetVisible");
893+
if (!engEvalString) module_->error("Cannot find engEvalString");
894+
if (!engOutputBuffer) module_->error("Cannot find engOutputBuffer");
895+
module_->error("Could not open matlab engine functions from matlab library");
896896
return false;
897897
}
898898
}
@@ -915,8 +915,7 @@ bool InterfaceWithMatlabImpl::open_matlab_engine()
915915

916916
if (!engine_)
917917
{
918-
module_->error(std::string("InterfaceWithMatlab: Could not open matlab engine"));
919-
module_->error(std::string("InterfaceWithMatlab: Check remote address information, or leave all fields except 'session' blank to connect to local matlab engine"));
918+
module_->error("InterfaceWithMatlab: Could not open matlab engine. Check remote address information, or leave all fields except 'session' blank to connect to local matlab engine.");
920919
return false;
921920
}
922921

@@ -926,24 +925,24 @@ bool InterfaceWithMatlabImpl::open_matlab_engine()
926925

927926

928927
file_transfer_.reset(new FileTransferClient());
929-
if (!(file_transfer_->open(address, "matlabenginefiletransfer", sessionnum, passwd)))
928+
if (!file_transfer_->open(address, "matlabenginefiletransfer", sessionnum, passwd))
930929
{
931930
std::string err;
932931
#ifndef USE_MATLAB_ENGINE_LIBRARY
933932
err = matlab_engine_->geterror();
934933
matlab_engine_->close();
935-
matlab_engine_ = 0;
934+
matlab_engine_.reset();
936935
#else
937936
engClose(engine_);
938937
engine_ = 0;
939938
#endif
940-
std::cout << "ERROR" << file_transfer_->geterror() << std::endl;
941-
module_->error(std::string("InterfaceWithMatlab: Could not open matlab engine file transfer service (error=") + err + std::string(")"));
942-
module_->error(std::string("InterfaceWithMatlab: Make sure the matlab engine file transfer service has not been disabled in [MATLAB_DIRECTPRY]/services/matlabengine.rc"));
943-
module_->error(std::string("InterfaceWithMatlab: Press the 'Edit Local Config of Matlab Engine' to change the configuration"));
944-
module_->error(std::string("InterfaceWithMatlab: Check remote address information, or leave all fields except 'session' blank to connect to local matlab engine"));
945-
946-
file_transfer_ = 0;
939+
std::ostringstream ostr;
940+
ostr << "InterfaceWithMatlab: Could not open matlab engine file transfer service (error=" << err << ")" <<
941+
".\n Make sure the matlab engine file transfer service has not been disabled in [MATLAB_DIRECTPRY]/services/matlabengine.rc.\n" <<
942+
" Press the 'Edit Local Config of Matlab Engine' to change the configuration." <<
943+
" Check remote address information, or leave all fields except 'session' blank to connect to local matlab engine.";
944+
module_->error(ostr.str());
945+
file_transfer_.reset();
947946
return(false);
948947
}
949948

@@ -960,14 +959,14 @@ bool InterfaceWithMatlabImpl::open_matlab_engine()
960959
{
961960
#ifndef USE_MATLAB_ENGINE_LIBRARY
962961
matlab_engine_->close();
963-
matlab_engine_ = 0;
962+
matlab_engine_.reset();
964963
#else
965964
engClose(engine_);
966965
engine_ = 0;
967966
#endif
968-
module_->error(std::string("InterfaceWithMatlab: Could not create remote temporary directory"));
967+
module_->error("InterfaceWithMatlab: Could not create remote temporary directory.");
969968
file_transfer_->close();
970-
file_transfer_ = 0;
969+
file_transfer_.reset();
971970
return(false);
972971
}
973972
file_transfer_->set_local_dir(temp_directory_);
@@ -991,9 +990,11 @@ bool InterfaceWithMatlabImpl::open_matlab_engine()
991990
{
992991
matlab_engine_->close();
993992
file_transfer_->close();
994-
module_->error(std::string("InterfaceWithMatlab: Could not get answer from matlab engine (error=") + matlab_engine_->geterror() + std::string(")"));
995-
module_->error(std::string("InterfaceWithMatlab: This is an internal communication error, make sure that the portnumber is correct"));
996-
module_->error(std::string("InterfaceWithMatlab: If address information is correct, this most probably points to a bug in the SCIRun software"));
993+
std::ostringstream ostr;
994+
ostr << "Could not get answer from matlab engine (error=" << matlab_engine_->geterror() << ").\n " <<
995+
" This is an internal communication error, make sure that the portnumber is correct. \n" <<
996+
" If address information is correct, this most probably points to a bug in the SCIRun software.";
997+
module_->error(ostr.str());
997998

998999
matlab_engine_.reset();
9991000
file_transfer_.reset();
@@ -1007,11 +1008,13 @@ bool InterfaceWithMatlabImpl::open_matlab_engine()
10071008
matlab_engine_->close();
10081009
file_transfer_->close();
10091010

1010-
module_->error(std::string("InterfaceWithMatlab: InterfaceWithMatlab engine returned an error (error=") + packet->getstring() + std::string(")"));
1011-
module_->error(std::string("InterfaceWithMatlab: Please check whether '[MATLAB_DIRECTORY]/services/matlabengine.rc' has been setup properly"));
1012-
module_->error(std::string("InterfaceWithMatlab: Press the 'Edit Local Config of Matlab Engine' to change the configuration"));
1013-
module_->error(std::string("InterfaceWithMatlab: Edit the 'startmatlab=' line to start matlab properly"));
1014-
module_->error(std::string("InterfaceWithMatlab: If you running matlab remotely, this file must be edited on the machine running matlab"));
1011+
std::ostringstream ostr;
1012+
ostr << "InterfaceWithMatlab engine returned an error (error=" << packet->getstring() << ")" <<
1013+
"\n Please check whether '[MATLAB_DIRECTORY]/services/matlabengine.rc' has been setup properly." <<
1014+
"\n Press the 'Edit Local Config of Matlab Engine' to change the configuration." <<
1015+
"\n Edit the 'startmatlab=' line to start matlab properly. " <<
1016+
"\n If you running matlab remotely, this file must be edited on the machine running matlab.";
1017+
module_->error(ostr.str());
10151018

10161019
matlab_engine_.reset();
10171020
file_transfer_.reset();

0 commit comments

Comments
 (0)