Skip to content

Commit 91ce37b

Browse files
committed
Module positioning issues improved
1 parent eb13509 commit 91ce37b

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
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() + 500)));
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()

0 commit comments

Comments
 (0)