Path: blob/devel/ElmerGUI/Application/src/objectbrowser.cpp
3203 views
/*****************************************************************************1* *2* Elmer, A Finite Element Software for Multiphysical Problems *3* *4* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *5* *6* This program is free software; you can redistribute it and/or *7* modify it under the terms of the GNU General Public License *8* as published by the Free Software Foundation; either version 2 *9* of the License, or (at your option) any later version. *10* *11* This program is distributed in the hope that it will be useful, *12* but WITHOUT ANY WARRANTY; without even the implied warranty of *13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *14* GNU General Public License for more details. *15* *16* You should have received a copy of the GNU General Public License *17* along with this program (in file fem/GPL-2); if not, write to the *18* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *19* Boston, MA 02110-1301, USA. *20* *21*****************************************************************************/2223/*****************************************************************************24* *25* ElmerGUI objectbrowser.cpp *26* *27*****************************************************************************28* *29* Author: Saeki Takayuki *30* Original Date: 11 Jan 2020 *31* *32*****************************************************************************/3334#include "objectbrowser.h"35#include "mainwindow.h"36#include <QSettings>37#include <QtGui>38#include <iostream>3940using namespace std;4142ObjectBrowser::ObjectBrowser(QMainWindow *parent, Qt::WindowFlags flags)43: QDockWidget("Object Browser", parent, flags) {44setTitleBarWidget(new QWidget());45setFeatures(QDockWidget::NoDockWidgetFeatures /*QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable*/);46setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);47if (parent)48parent->addDockWidget(Qt::LeftDockWidgetArea, this);4950tree = new QTreeWidget(this);51tree->setColumnCount(2);52QStringList headerLabels;53headerLabels << "Object"54<< "Value";55tree->setHeaderLabels(headerLabels);5657geometryTopLevelTreeItem = new QTreeWidgetItem();58modelTopLevelTreeItem = new QTreeWidgetItem();59geometryTopLevelTreeItem->setText(0, "Geometry");60modelTopLevelTreeItem->setText(0, "Model");6162bodyPropertyParentTreeItem = new QTreeWidgetItem();63boundaryPropertyParentTreeItem = new QTreeWidgetItem();64geometryParentTreeItem = new QTreeWidgetItem();65setupParentTreeItem = new QTreeWidgetItem();66equationParentTreeItem = new QTreeWidgetItem();67materialParentTreeItem = new QTreeWidgetItem();68bodyForceParentTreeItem = new QTreeWidgetItem();69initialConditionParentTreeItem = new QTreeWidgetItem();70boundaryConditionParentTreeItem = new QTreeWidgetItem();7172bodyPropertyParentTreeItem->setText(0, "Body");73boundaryPropertyParentTreeItem->setText(0, "Boundary");74geometryParentTreeItem->setText(0, "Input file");75setupParentTreeItem->setText(0, "Setup");76equationParentTreeItem->setText(0, "Equation");77equationParentTreeItem->setText(1, "[Add...]");78materialParentTreeItem->setText(0, "Material");79materialParentTreeItem->setText(1, "[Add...]");80bodyForceParentTreeItem->setText(0, "Body force");81bodyForceParentTreeItem->setText(1, "[Add...]");82initialConditionParentTreeItem->setText(0, "Initial condition");83initialConditionParentTreeItem->setText(1, "[Add...]");84boundaryConditionParentTreeItem->setText(0, "Boundary condition");85boundaryConditionParentTreeItem->setText(1, "[Add...]");8687tree->addTopLevelItem(geometryTopLevelTreeItem);88tree->addTopLevelItem(modelTopLevelTreeItem);8990geometryTopLevelTreeItem->addChild(geometryParentTreeItem);91geometryTopLevelTreeItem->addChild(bodyPropertyParentTreeItem);92geometryTopLevelTreeItem->addChild(boundaryPropertyParentTreeItem);93// modelTopLevelTreeItem->addChild(setupParentTreeItem); Setup will not be94// used so frequently...95modelTopLevelTreeItem->addChild(equationParentTreeItem);96modelTopLevelTreeItem->addChild(materialParentTreeItem);97modelTopLevelTreeItem->addChild(bodyForceParentTreeItem);98modelTopLevelTreeItem->addChild(initialConditionParentTreeItem);99modelTopLevelTreeItem->addChild(boundaryConditionParentTreeItem);100101geometryTopLevelTreeItem->setExpanded(true);102modelTopLevelTreeItem->setExpanded(true);103tree->resizeColumnToContents(0);104tree->resizeColumnToContents(1);105106setWidget(tree);107108mainWindow = parent;109MainWindow *mainwindow = (MainWindow *)mainWindow;110111connect(mainwindow->modelSetupAct, SIGNAL(triggered()), this,112SLOT(modelSetupSlot()));113connect(mainwindow->addEquationAct, SIGNAL(triggered()), this,114SLOT(addEquationSlot()));115connect(mainwindow->addMaterialAct, SIGNAL(triggered()), this,116SLOT(addMaterialSlot()));117connect(mainwindow->addBodyForceAct, SIGNAL(triggered()), this,118SLOT(addBodyForceSlot()));119connect(mainwindow->addInitialConditionAct, SIGNAL(triggered()), this,120SLOT(addInitialConditionSlot()));121connect(mainwindow->addBoundaryConditionAct, SIGNAL(triggered()), this,122SLOT(addBoundaryConditionSlot()));123connect(mainwindow->equationMenu, SIGNAL(triggered(QAction *)), this,124SLOT(equationSelectedSlot(QAction *)));125connect(mainwindow->materialMenu, SIGNAL(triggered(QAction *)), this,126SLOT(materialSelectedSlot(QAction *)));127connect(mainwindow->bodyForceMenu, SIGNAL(triggered(QAction *)), this,128SLOT(bodyForceSelectedSlot(QAction *)));129connect(mainwindow->initialConditionMenu, SIGNAL(triggered(QAction *)), this,130SLOT(initialConditionSelectedSlot(QAction *)));131connect(mainwindow->boundaryConditionMenu, SIGNAL(triggered(QAction *)), this,132SLOT(boundaryConditionSelectedSlot(QAction *)));133connect(tree, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,134SLOT(treeItemClickedSlot(QTreeWidgetItem *, int)));135connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this,136SLOT(treeItemDoubleClickedSlot(QTreeWidgetItem *, int)));137connect(tree, SIGNAL(itemExpanded(QTreeWidgetItem *)), this,138SLOT(treeItemExpandedSlot(139QTreeWidgetItem *))); // used to update body and boundary parent140connect(tree, SIGNAL(itemSelectionChanged()), this,141SLOT(treeItemSelectionChangedSlot()));142connect(mainwindow->openAct, SIGNAL(triggered()), this, SLOT(openSlot()));143connect(mainwindow->loadAct, SIGNAL(triggered()), this, SLOT(loadSlot()));144connect(mainwindow->loadProjectAct, SIGNAL(triggered()), this,145SLOT(loadProjectSlot()));146connect(mainwindow->recentProject0Act, SIGNAL(triggered()), this,147SLOT(loadProjectSlot()));148connect(mainwindow->recentProject1Act, SIGNAL(triggered()), this,149SLOT(loadProjectSlot()));150connect(mainwindow->recentProject2Act, SIGNAL(triggered()), this,151SLOT(loadProjectSlot()));152connect(mainwindow->recentProject3Act, SIGNAL(triggered()), this,153SLOT(loadProjectSlot()));154connect(mainwindow->recentProject4Act, SIGNAL(triggered()), this,155SLOT(loadProjectSlot()));156connect(mainwindow->saveProjectAct, SIGNAL(triggered()), this,157SLOT(saveProjectSlot()));158connect(mainwindow->newProjectAct, SIGNAL(triggered()), this,159SLOT(newProjectSlot()));160connect(mainwindow->modelClearAct, SIGNAL(triggered()), this,161SLOT(modelClearSlot()));162163connect(mainwindow->viewFullScreenAct, SIGNAL(triggered()), this,164SLOT(viewFullScreenSlot()));165connect(mainwindow->glWidget, SIGNAL(escPressed()), this,166SLOT(viewNormalModeSlot()));167168connect(mainwindow->boundaryDivide, SIGNAL(signalDoDivideSurface(double)),169this, SLOT(boundaryDividedSlot(double)));170connect(mainwindow->boundaryDivide, SIGNAL(signalDoDivideEdge(double)), this,171SLOT(boundaryDividedSlot(double)));172connect(mainwindow->surfaceUnifyAct, SIGNAL(triggered()), this,173SLOT(boundaryUnifiedSlot()));174connect(mainwindow->edgeUnifyAct, SIGNAL(triggered()), this,175SLOT(boundaryUnifiedSlot()));176177connect(mainwindow->glWidget, SIGNAL(signalBoundarySelected(list_t *, Qt::KeyboardModifiers)), this,178SLOT(boundarySelectedSlot(list_t *, Qt::KeyboardModifiers)));179180connect(mainwindow->meshingThread, SIGNAL(started()), this,181SLOT(meshingStartedSlot()));182connect(mainwindow->meshingThread, SIGNAL(finished()), this,183SLOT(meshingFinishedSlot()));184connect(mainwindow->meshingThread, SIGNAL(terminated()), this,185SLOT(meshingTerminatedSlot()));186187QApplication *q = (QApplication *)QCoreApplication::instance();188connect(q, SIGNAL(focusChanged(QWidget *, QWidget *)), this,189SLOT(focusChangedSlot(QWidget *, QWidget *)));190191connect(mainwindow->newProjectAct, SIGNAL(triggered()), this,192SLOT(loadProjectSlot()));193194loadProjectSlot();195}196197ObjectBrowser::~ObjectBrowser() {}198199void ObjectBrowser::focusChangedSlot(QWidget *old, QWidget *now) {200201if (now == NULL)202return;203204QWidget *p = now->parentWidget();205while (p != NULL) {206now = p;207p = now->parentWidget();208}209210MainWindow *mainwindow = (MainWindow *)mainWindow;211212if (now->windowTitle() == "Equation") {213selectTreeItemByID(equationParentTreeItem, ((DynamicEditor *)now)->ID);214return;215}216if (now->windowTitle() == "Material") {217selectTreeItemByID(materialParentTreeItem, ((DynamicEditor *)now)->ID);218return;219}220if (now->windowTitle() == "BodyForce") {221selectTreeItemByID(bodyForceParentTreeItem, ((DynamicEditor *)now)->ID);222return;223}224if (now->windowTitle() == "InitialCondition") {225selectTreeItemByID(initialConditionParentTreeItem,226((DynamicEditor *)now)->ID);227return;228}229if (now->windowTitle() == "BoundaryCondition") {230selectTreeItemByID(boundaryConditionParentTreeItem,231((DynamicEditor *)now)->ID);232return;233}234if (now->windowTitle().indexOf(QString("Properties for body")) == 0) {235int n = bodyPropertyParentTreeItem->childCount();236for (int i = 0; i < n; i++) {237QTreeWidgetItem *item = bodyPropertyParentTreeItem->child(i);238if (item->data(0, Qt::UserRole).value<qulonglong>() == (qulonglong)now) {239tree->setCurrentItem(item);240return;241}242}243return;244}245if (now->windowTitle().indexOf(QString("Properties for boundary")) == 0) {246int n = boundaryPropertyParentTreeItem->childCount();247for (int i = 0; i < n; i++) {248QTreeWidgetItem *item = boundaryPropertyParentTreeItem->child(i);249if (item->data(0, Qt::UserRole).value<qulonglong>() == (qulonglong)now) {250tree->setCurrentItem(item);251return;252}253}254return;255}256}257258void ObjectBrowser::treeItemClickedSlot(QTreeWidgetItem *item, int column) {259MainWindow* mainwindow = (MainWindow*) mainWindow;260261// clicking [Add...] button262if (item == equationParentTreeItem) {263if (column == 1) {264mainwindow->addEquationSlot();265addEquationSlot();266}267return;268}269if (item == materialParentTreeItem) {270if (column == 1) {271mainwindow->addMaterialSlot();272addMaterialSlot();273}274return;275}276if (item == bodyForceParentTreeItem) {277if (column == 1) {278mainwindow->addBodyForceSlot();279addBodyForceSlot();280}281return;282}283if (item == initialConditionParentTreeItem) {284if (column == 1) {285mainwindow->addInitialConditionSlot();286addInitialConditionSlot();287}288return;289}290if (item == boundaryConditionParentTreeItem) {291if (column == 1) {292mainwindow->addBoundaryConditionSlot();293addBoundaryConditionSlot();294}295return;296}297}298299void ObjectBrowser::treeItemDoubleClickedSlot(QTreeWidgetItem *item,300int column) {301302MainWindow *mainwindow = (MainWindow *)mainWindow;303304// Show selected dynamic editor305if (item->parent() == equationParentTreeItem) {306DynamicEditor *pe =307(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();308// snap(pe);309mainwindow->equationSelectedSlot(pe->menuAction);310311QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();312if (!mainwindow->glWidget->hasMesh() || box == NULL)313return;314for (int i = 2; i < box->children().size(); i++) {315QCheckBox *cb = (QCheckBox *)box->children()[i];316connect1(cb, SIGNAL(stateChanged(int)), this,317SLOT(bodyCheckBoxChangedSlot(int)));318}319320return;321}322if (item->parent() == materialParentTreeItem) {323DynamicEditor *pe =324(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();325// snap(pe);326mainwindow->materialSelectedSlot(pe->menuAction);327328QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();329if (!mainwindow->glWidget->hasMesh() || box == NULL)330return;331for (int i = 2; i < box->children().size(); i++) {332QCheckBox *cb = (QCheckBox *)box->children()[i];333connect1(cb, SIGNAL(stateChanged(int)), this,334SLOT(bodyCheckBoxChangedSlot(int)));335}336337return;338}339if (item->parent() == bodyForceParentTreeItem) {340DynamicEditor *pe =341(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();342// snap(pe);343mainwindow->bodyForceSelectedSlot(pe->menuAction);344345QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();346if (!mainwindow->glWidget->hasMesh() || box == NULL)347return;348for (int i = 2; i < box->children().size(); i++) {349QCheckBox *cb = (QCheckBox *)box->children()[i];350connect1(cb, SIGNAL(stateChanged(int)), this,351SLOT(bodyCheckBoxChangedSlot(int)));352}353354return;355}356if (item->parent() == initialConditionParentTreeItem) {357DynamicEditor *pe =358(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();359// snap(pe);360mainwindow->initialConditionSelectedSlot(pe->menuAction);361362QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();363if (!mainwindow->glWidget->hasMesh() || box == NULL)364return;365for (int i = 2; i < box->children().size(); i++) {366QCheckBox *cb = (QCheckBox *)box->children()[i];367connect1(cb, SIGNAL(stateChanged(int)), this,368SLOT(bodyCheckBoxChangedSlot(int)));369}370371return;372}373if (item->parent() == boundaryConditionParentTreeItem) {374DynamicEditor *pe =375(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();376// snap(pe);377mainwindow->boundaryConditionSelectedSlot(pe->menuAction);378379// connect checkbox380QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();381if (!mainwindow->glWidget->hasMesh() || box == NULL)382return;383for (int i = 2; i < box->children().size(); i++) {384QCheckBox *cb = (QCheckBox *)box->children()[i];385connect1(cb, SIGNAL(stateChanged(int)), this,386SLOT(boundaryCheckBoxChangedSlot(int)));387}388389return;390}391392// show property editor393// bool bodyEditActive = mainwindow->bodyEditActive;394// bool bcEditActive = mainwindow->bcEditActive;395if (item->parent() == boundaryPropertyParentTreeItem) {396BoundaryPropertyEditor *pe =397(BoundaryPropertyEditor *)item->data(0, Qt::UserRole)398.value<qulonglong>();399if (pe == NULL) {400cout << " BoundaryPropertyEditor NULL" << endl;401return;402}403list_t *l = selectBoundary(pe);404mainwindow->bcEditActive = true;405mainwindow->bodyEditActive = false;406mainwindow->glWidget->bodyEditActive = false;407mainwindow->bcEditAct->setChecked(true);408mainwindow->bodyEditAct->setChecked(false);409mainwindow->boundarySelectedSlot(l, Qt::NoModifier);410// mainwindow->bcEditActive = bcEditActive;411// mainwindow->bodyEditActive = bodyEditActive;412connect1(413pe, SIGNAL(BoundaryComboChanged(BoundaryPropertyEditor *, QString)),414this, SLOT(boundaryComboChanged(BoundaryPropertyEditor *, QString)));415connect1(pe->ui.applyButton, SIGNAL(clicked(bool)), this,416SLOT(boundaryPropertyEditorAccepted(bool)));417connect1(pe->ui.discardButton, SIGNAL(clicked(bool)), this,418SLOT(boundaryPropertyEditorDiscarded(bool)));419snap(pe);420pe->show();421pe->raise();422return;423}424if (item->parent() != NULL &&425item->parent()->parent() == boundaryPropertyParentTreeItem) {426BoundaryPropertyEditor *pe = (BoundaryPropertyEditor *)item->parent()427->data(0, Qt::UserRole)428.value<qulonglong>();429if (pe == NULL) {430cout << " BoundaryPropertyEditor NULL" << endl;431return;432}433list_t *l = selectBoundary(pe);434mainwindow->bcEditActive = true;435mainwindow->bodyEditActive = false;436mainwindow->glWidget->bodyEditActive = false;437mainwindow->bcEditAct->setChecked(true);438mainwindow->bodyEditAct->setChecked(false);439mainwindow->boundarySelectedSlot(l, Qt::NoModifier);440// mainwindow->bcEditActive = bcEditActive;441// mainwindow->bodyEditActive = bodyEditActive;442connect1(443pe, SIGNAL(BoundaryComboChanged(BoundaryPropertyEditor *, QString)),444this, SLOT(boundaryComboChanged(BoundaryPropertyEditor *, QString)));445connect1(pe->ui.applyButton, SIGNAL(clicked(bool)), this,446SLOT(boundaryPropertyEditorAccepted(bool)));447connect1(pe->ui.discardButton, SIGNAL(clicked(bool)), this,448SLOT(boundaryPropertyEditorDiscarded(bool)));449snap(pe);450pe->show();451pe->raise();452return;453}454if (item->parent() == bodyPropertyParentTreeItem) {455BodyPropertyEditor *pe =456(BodyPropertyEditor *)item->data(0, Qt::UserRole).value<qulonglong>();457if (pe == NULL) {458cout << " BodyPropertyEditor NULL" << endl;459return;460}461list_t *l = selectBody(pe);462mainwindow->bcEditActive = false;463mainwindow->bodyEditActive = true;464mainwindow->glWidget->bodyEditActive = true;465mainwindow->bcEditAct->setChecked(false);466mainwindow->bodyEditAct->setChecked(true);467mainwindow->boundarySelectedSlot(l, Qt::NoModifier);468// mainwindow->bcEditActive = bcEditActive;469// mainwindow->bodyEditActive = bodyEditActive;470connect1(pe,471SIGNAL(BodyMaterialComboChanged(BodyPropertyEditor *, QString)),472this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));473connect1(pe, SIGNAL(BodyInitialComboChanged(BodyPropertyEditor *, QString)),474this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));475connect1(pe, SIGNAL(BodyForceComboChanged(BodyPropertyEditor *, QString)),476this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));477connect1(pe,478SIGNAL(BodyEquationComboChanged(BodyPropertyEditor *, QString)),479this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));480connect1(pe->ui.applyButton, SIGNAL(clicked(bool)), this,481SLOT(bodyPropertyEditorAccepted(bool)));482connect1(pe->ui.discardButton, SIGNAL(clicked(bool)), this,483SLOT(bodyPropertyEditorDiscarded(bool)));484snap(pe);485pe->show();486pe->raise();487tree->collapseItem(item);488return;489}490if (item->parent() != NULL &&491item->parent()->parent() == bodyPropertyParentTreeItem) {492BodyPropertyEditor *pe = (BodyPropertyEditor *)item->parent()493->data(0, Qt::UserRole)494.value<qulonglong>();495if (pe == NULL) {496cout << " BodyPropertyEditor NULL" << endl;497return;498}499list_t *l = selectBody(pe);500mainwindow->bcEditActive = false;501mainwindow->bodyEditActive = true;502mainwindow->glWidget->bodyEditActive = true;503mainwindow->bcEditAct->setChecked(false);504mainwindow->bodyEditAct->setChecked(true);505mainwindow->boundarySelectedSlot(l, Qt::NoModifier);506// mainwindow->bcEditActive = bcEditActive;507// mainwindow->bodyEditActive = bodyEditActive;508connect1(pe,509SIGNAL(BodyMaterialComboChanged(BodyPropertyEditor *, QString)),510this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));511connect1(pe, SIGNAL(BodyInitialComboChanged(BodyPropertyEditor *, QString)),512this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));513connect1(pe, SIGNAL(BodyForceComboChanged(BodyPropertyEditor *, QString)),514this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));515connect1(pe,516SIGNAL(BodyEquationComboChanged(BodyPropertyEditor *, QString)),517this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));518connect1(pe->ui.applyButton, SIGNAL(clicked(bool)), this,519SLOT(bodyPropertyEditorAccepted(bool)));520connect1(pe->ui.discardButton, SIGNAL(clicked(bool)), this,521SLOT(bodyPropertyEditorDiscarded(bool)));522snap(pe);523pe->show();524pe->raise();525return;526}527}528529void ObjectBrowser::addToTree(DynamicEditor *de, bool select /*= false*/) {530if (de == NULL)531return;532if (de->ID < 0)533return; // removed item534QTreeWidgetItem *treeItem = new QTreeWidgetItem();535treeItem->setText(0,536de->nameEdit->text()537.trimmed()); // +" [" + QString::number(de->ID) + "]");538QString title = de->windowTitle();539if (title == "Equation") {540equationParentTreeItem->addChild(treeItem);541connect1(de, SIGNAL(dynamicEditorReady(int, int)), this,542SLOT(equationEditorFinishedSlot(int, int)));543544QGroupBox *box = (QGroupBox *)de->spareScroll->widget();545bool used = false;546if (box != NULL) {547for (int i = 2; i < box->children().size(); i++) {548QCheckBox *cb = (QCheckBox *)box->children()[i];549connect1(cb, SIGNAL(stateChanged(int)), this,550SLOT(bodyCheckBoxChangedSlot(int)));551used |= cb->isChecked();552}553}554// if(!used) treeItem->setText(0, "*" + de->nameEdit->text().trimmed());555} else if (title == "Material") {556materialParentTreeItem->addChild(treeItem);557connect1(de, SIGNAL(dynamicEditorReady(int, int)), this,558SLOT(materialEditorFinishedSlot(int, int)));559560QGroupBox *box = (QGroupBox *)de->spareScroll->widget();561bool used = false;562if (box != NULL) {563for (int i = 2; i < box->children().size(); i++) {564QCheckBox *cb = (QCheckBox *)box->children()[i];565connect1(cb, SIGNAL(stateChanged(int)), this,566SLOT(bodyCheckBoxChangedSlot(int)));567used |= cb->isChecked();568}569}570// if(!used) treeItem->setText(0, "*" + de->nameEdit->text().trimmed());571} else if (title == "BodyForce") {572bodyForceParentTreeItem->addChild(treeItem);573connect1(de, SIGNAL(dynamicEditorReady(int, int)), this,574SLOT(bodyForceEditorFinishedSlot(int, int)));575576QGroupBox *box = (QGroupBox *)de->spareScroll->widget();577bool used = false;578if (box != NULL) {579for (int i = 2; i < box->children().size(); i++) {580QCheckBox *cb = (QCheckBox *)box->children()[i];581connect1(cb, SIGNAL(stateChanged(int)), this,582SLOT(bodyCheckBoxChangedSlot(int)));583used |= cb->isChecked();584}585}586// if(!used) treeItem->setText(0, "*" + de->nameEdit->text().trimmed());587} else if (title == "InitialCondition") {588initialConditionParentTreeItem->addChild(treeItem);589connect1(de, SIGNAL(dynamicEditorReady(int, int)), this,590SLOT(initialConditionEditorFinishedSlot(int, int)));591592QGroupBox *box = (QGroupBox *)de->spareScroll->widget();593bool used = false;594if (box != NULL) {595for (int i = 2; i < box->children().size(); i++) {596QCheckBox *cb = (QCheckBox *)box->children()[i];597connect1(cb, SIGNAL(stateChanged(int)), this,598SLOT(bodyCheckBoxChangedSlot(int)));599used |= cb->isChecked();600}601}602// if(!used) treeItem->setText(0, "*" + de->nameEdit->text().trimmed());603} else if (title == "BoundaryCondition") {604boundaryConditionParentTreeItem->addChild(treeItem);605connect1(de, SIGNAL(dynamicEditorReady(int, int)), this,606SLOT(boundaryConditionEditorFinishedSlot(int, int)));607608QGroupBox *box = (QGroupBox *)de->spareScroll->widget();609bool used = false;610if (box != NULL) {611for (int i = 2; i < box->children().size(); i++) {612QCheckBox *cb = (QCheckBox *)box->children()[i];613connect1(cb, SIGNAL(stateChanged(int)), this,614SLOT(boundaryCheckBoxChangedSlot(int)));615used |= cb->isChecked();616}617}618// if(!used) treeItem->setText(0, "*" + de->nameEdit->text().trimmed());619} else {620cout << " ***Warning*** In ObjectBrowser::addTotree(), the DynamicEditor "621"did not match to any of categories.";622}623624treeItem->setData(0, Qt::UserRole, QVariant::fromValue((qulonglong)de));625if (select)626tree->setCurrentItem(treeItem);627else628treeItem->parent()->setExpanded(true);629630// tree->resizeColumnToContents(0);631// tree->resizeColumnToContents(1);632}633634void ObjectBrowser::modelSetupSlot() {}635void ObjectBrowser::addEquationSlot() {636MainWindow *mainwindow = (MainWindow *)mainWindow;637DynamicEditor *de = (DynamicEditor *)mainwindow->equationEditor.last();638addToTree(de, true);639snap(de);640}641void ObjectBrowser::addMaterialSlot() {642MainWindow *mainwindow = (MainWindow *)mainWindow;643DynamicEditor *de = (DynamicEditor *)mainwindow->materialEditor.last();644addToTree(de, true);645snap(de);646}647void ObjectBrowser::addBodyForceSlot() {648MainWindow *mainwindow = (MainWindow *)mainWindow;649DynamicEditor *de = (DynamicEditor *)mainwindow->bodyForceEditor.last();650addToTree(de, true);651snap(de);652}653void ObjectBrowser::addInitialConditionSlot() {654MainWindow *mainwindow = (MainWindow *)mainWindow;655DynamicEditor *de =656(DynamicEditor *)mainwindow->initialConditionEditor.last();657addToTree(de, true);658snap(de);659}660void ObjectBrowser::addBoundaryConditionSlot() {661MainWindow *mainwindow = (MainWindow *)mainWindow;662DynamicEditor *de =663(DynamicEditor *)mainwindow->boundaryConditionEditor.last();664addToTree(de, true);665snap(de);666}667void ObjectBrowser::equationSelectedSlot(QAction *action) {668int n = equationParentTreeItem->childCount();669for (int i = 0; i < n; i++) {670QTreeWidgetItem *child = equationParentTreeItem->child(i);671DynamicEditor *de =672(DynamicEditor *)child->data(0, Qt::UserRole).value<qulonglong>();673if (de->menuAction == action) {674tree->setCurrentItem(child);675return;676}677}678}679void ObjectBrowser::materialSelectedSlot(QAction *action) {680int n = materialParentTreeItem->childCount();681for (int i = 0; i < n; i++) {682QTreeWidgetItem *child = materialParentTreeItem->child(i);683DynamicEditor *de =684(DynamicEditor *)child->data(0, Qt::UserRole).value<qulonglong>();685if (de->menuAction == action) {686tree->setCurrentItem(child);687return;688}689}690}691void ObjectBrowser::bodyForceSelectedSlot(QAction *action) {692int n = bodyForceParentTreeItem->childCount();693for (int i = 0; i < n; i++) {694QTreeWidgetItem *child = bodyForceParentTreeItem->child(i);695DynamicEditor *de =696(DynamicEditor *)child->data(0, Qt::UserRole).value<qulonglong>();697if (de->menuAction == action) {698tree->setCurrentItem(child);699return;700}701}702}703void ObjectBrowser::initialConditionSelectedSlot(QAction *action) {704int n = initialConditionParentTreeItem->childCount();705for (int i = 0; i < n; i++) {706QTreeWidgetItem *child = initialConditionParentTreeItem->child(i);707DynamicEditor *de =708(DynamicEditor *)child->data(0, Qt::UserRole).value<qulonglong>();709if (de->menuAction == action) {710tree->setCurrentItem(child);711return;712}713}714}715void ObjectBrowser::boundaryConditionSelectedSlot(QAction *action) {716int n = boundaryConditionParentTreeItem->childCount();717for (int i = 0; i < n; i++) {718QTreeWidgetItem *child = boundaryConditionParentTreeItem->child(i);719DynamicEditor *de =720(DynamicEditor *)child->data(0, Qt::UserRole).value<qulonglong>();721if (de->menuAction == action) {722tree->setCurrentItem(child);723return;724}725}726}727728void ObjectBrowser::equationEditorFinishedSlot(int signal, int id) {729updateEquation();730updateBodyProperties();731updateBoundaryProperties();732if (signal != MAT_NEW)733selectTreeItemByID(equationParentTreeItem, id);734else {735MainWindow *mainwindow = (MainWindow *)mainWindow;736DynamicEditor *de = mainwindow->equationEditor.last();737if (de != NULL)738selectTreeItemByID(equationParentTreeItem, de->ID);739else740selectTreeItemByID(equationParentTreeItem, -1);741}742}743744void ObjectBrowser::materialEditorFinishedSlot(int signal, int id) {745updateMaterial();746updateBodyProperties();747updateBoundaryProperties();748if (signal != MAT_NEW)749selectTreeItemByID(materialParentTreeItem, id);750else {751MainWindow *mainwindow = (MainWindow *)mainWindow;752DynamicEditor *de = mainwindow->materialEditor.last();753if (de != NULL)754selectTreeItemByID(materialParentTreeItem, de->ID);755else756selectTreeItemByID(materialParentTreeItem, -1);757}758}759760void ObjectBrowser::bodyForceEditorFinishedSlot(int signal, int id) {761updateBodyForce();762updateBodyProperties();763updateBoundaryProperties();764if (signal != MAT_NEW)765selectTreeItemByID(bodyForceParentTreeItem, id);766else {767MainWindow *mainwindow = (MainWindow *)mainWindow;768DynamicEditor *de = mainwindow->bodyForceEditor.last();769if (de != NULL)770selectTreeItemByID(bodyForceParentTreeItem, de->ID);771else772selectTreeItemByID(bodyForceParentTreeItem, -1);773}774}775776void ObjectBrowser::initialConditionEditorFinishedSlot(int signal, int id) {777updateInitialCondition();778updateBodyProperties();779updateBoundaryProperties();780if (signal != MAT_NEW)781selectTreeItemByID(initialConditionParentTreeItem, id);782else {783MainWindow *mainwindow = (MainWindow *)mainWindow;784DynamicEditor *de = mainwindow->initialConditionEditor.last();785if (de != NULL)786selectTreeItemByID(initialConditionParentTreeItem, de->ID);787else788selectTreeItemByID(initialConditionParentTreeItem, -1);789}790}791792void ObjectBrowser::boundaryConditionEditorFinishedSlot(int signal, int id) {793updateBoundaryCondition();794updateBodyProperties();795updateBoundaryProperties();796if (signal != MAT_NEW)797selectTreeItemByID(boundaryConditionParentTreeItem, id);798else {799MainWindow *mainwindow = (MainWindow *)mainWindow;800DynamicEditor *de = mainwindow->boundaryConditionEditor.last();801if (de != NULL)802selectTreeItemByID(boundaryConditionParentTreeItem, de->ID);803else804selectTreeItemByID(boundaryConditionParentTreeItem, -1);805}806}807808void ObjectBrowser::openSlot() {809MainWindow *mainwindow = (MainWindow *)mainWindow;810QFileInfo fi(mainwindow->geometryInputFileName);811geometryParentTreeItem->setText(0, "Input file");812geometryParentTreeItem->setText(1, fi.fileName());813814bodyPropertyParentTreeItem->setExpanded(false);815bodyPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy816boundaryPropertyParentTreeItem->setExpanded(false);817boundaryPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy818}819820void ObjectBrowser::loadSlot() {821MainWindow *mainwindow = (MainWindow *)mainWindow;822QFileInfo fi(mainwindow->saveDirName);823geometryParentTreeItem->setText(0, "Elmer mesh dir");824geometryParentTreeItem->setText(1, fi.fileName());825826bodyPropertyParentTreeItem->setExpanded(false);827bodyPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy828boundaryPropertyParentTreeItem->setExpanded(false);829boundaryPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy830}831832void ObjectBrowser::loadProjectSlot() {833MainWindow *mainwindow = (MainWindow *)mainWindow;834if (mainwindow->currentProjectDirName.isEmpty())835return;836837modelClearSlot();838839int n = mainwindow->equationEditor.size();840for (int i = 0; i < n; i++) {841addToTree(mainwindow->equationEditor.at(i));842}843n = mainwindow->materialEditor.size();844for (int i = 0; i < n; i++) {845addToTree(mainwindow->materialEditor.at(i));846}847n = mainwindow->bodyForceEditor.size();848for (int i = 0; i < n; i++) {849addToTree(mainwindow->bodyForceEditor.at(i));850}851n = mainwindow->initialConditionEditor.size();852for (int i = 0; i < n; i++) {853addToTree(mainwindow->initialConditionEditor.at(i));854}855n = mainwindow->boundaryConditionEditor.size();856for (int i = 0; i < n; i++) {857addToTree(mainwindow->boundaryConditionEditor.at(i));858}859860if (!mainwindow->geometryInputFileName.isEmpty()) {861QFileInfo fi(mainwindow->geometryInputFileName);862geometryParentTreeItem->setText(0, "Input file");863geometryParentTreeItem->setText(1, fi.fileName());864} else if (!mainwindow->saveDirName.isEmpty()) {865QFileInfo fi(mainwindow->saveDirName);866geometryParentTreeItem->setText(0, "Elmer mesh dir");867geometryParentTreeItem->setText(1, fi.fileName());868} else {869geometryParentTreeItem->setText(0, "Input file");870geometryParentTreeItem->setText(1, "");871}872873bodyPropertyParentTreeItem->setExpanded(false);874bodyPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy875boundaryPropertyParentTreeItem->setExpanded(false);876boundaryPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy877878tree->resizeColumnToContents(0);879tree->resizeColumnToContents(1);880881/* Call rebuildGLLists() to avoid a problem of 3D surface mesh not shown882correctly when project loading (typically, TemperatureGeneric sample) */883mainwindow->rebuildGLLists();884}885886void ObjectBrowser::saveProjectSlot() {887MainWindow *mainwindow = (MainWindow *)mainWindow;888if (mainwindow->currentProjectDirName.isEmpty())889return;890891if (!mainwindow->geometryInputFileName.isEmpty()) {892QFileInfo fi(mainwindow->geometryInputFileName);893geometryParentTreeItem->setText(0, "Input file");894geometryParentTreeItem->setText(1, fi.fileName());895} else if (!mainwindow->saveDirName.isEmpty()) {896QFileInfo fi(mainwindow->saveDirName);897geometryParentTreeItem->setText(0, "Elmer mesh dir");898geometryParentTreeItem->setText(1, fi.fileName());899} else {900geometryParentTreeItem->setText(0, "Input file");901geometryParentTreeItem->setText(1, "");902}903}904905void ObjectBrowser::newProjectSlot() { modelClearSlot(); }906907void ObjectBrowser::modelClearSlot() {908geometryParentTreeItem->setText(1, "");909QTreeWidgetItem *treeItem = 0;910tree->setCurrentItem(geometryTopLevelTreeItem);911while (treeItem = bodyPropertyParentTreeItem->takeChild(0))912delete treeItem;913while (treeItem = boundaryPropertyParentTreeItem->takeChild(0))914delete treeItem;915while (treeItem = equationParentTreeItem->takeChild(0))916delete treeItem;917while (treeItem = materialParentTreeItem->takeChild(0))918delete treeItem;919while (treeItem = bodyForceParentTreeItem->takeChild(0))920delete treeItem;921while (treeItem = initialConditionParentTreeItem->takeChild(0))922delete treeItem;923while (treeItem = boundaryConditionParentTreeItem->takeChild(0))924delete treeItem;925926openSlot();927}928929void ObjectBrowser::treeItemExpandedSlot(930QTreeWidgetItem *item) { // used to update body and boundary parent931932if (item == bodyPropertyParentTreeItem) {933updateBodyProperties();934for (int i = 0; i < bodyPropertyParentTreeItem->childCount(); i++)935bodyPropertyParentTreeItem->child(i)->setExpanded(true);936updateBoundaryProperties(); // This was added to avoid crushing when choosing937// body property just after loading 3D mesh938// without expanding boundary condition parent939// item.940}941942if (item == boundaryPropertyParentTreeItem)943updateBoundaryProperties();944}945946void ObjectBrowser::updateBoundaryProperties(947BoundaryPropertyEditor *selectThis /*=NULL*/) {948949MainWindow *mainwindow = (MainWindow *)mainWindow;950if (tree->currentItem() != NULL &&951tree->currentItem()->parent() == boundaryPropertyParentTreeItem) {952tree->setCurrentItem(boundaryPropertyParentTreeItem); // to improve speed953}954QTreeWidgetItem *treeItem = 0;955while (treeItem = boundaryPropertyParentTreeItem->takeChild(0))956delete treeItem;957958QMapIterator<int, int> itr(mainwindow->glWidget->boundaryMap);959while (itr.hasNext()) {960itr.next();961int n = itr.key();962if (n >= 0) {963int m = itr.value();964965if (m >= mainwindow->boundaryPropertyEditor.size())966mainwindow->boundaryPropertyEditor.resize(m + 1);967968if (!mainwindow->boundaryPropertyEditor[m])969mainwindow->boundaryPropertyEditor[m] = new BoundaryPropertyEditor;970971BoundaryPropertyEditor *pe = mainwindow->boundaryPropertyEditor[m];972973treeItem = new QTreeWidgetItem();974boundaryPropertyParentTreeItem->addChild(treeItem);975976treeItem->setText(0, "Boundary " + QString::number(n));977// if(pe->touched && pe->condition != 0) treeItem->setText(0, "Boundary "978// + QString::number(n)); else treeItem->setText(0, "*Boundary " +979// QString::number(n));980981treeItem->setData(0, Qt::UserRole, QVariant::fromValue((qulonglong)pe));982if (pe->condition != 0) {983if (pe->touched)984treeItem->setText(1, pe->condition->nameEdit->text().trimmed());985else986treeItem->setText(1, "<Canceled>" +987pe->condition->nameEdit->text().trimmed());988treeItem->setData(1, Qt::UserRole,989QVariant::fromValue((qulonglong)pe->condition));990}991}992}993994if (selectThis != NULL) {995QTreeWidgetItem *item;996for (int i = 0; i < boundaryPropertyParentTreeItem->childCount(); i++) {997item = boundaryPropertyParentTreeItem->child(i);998if (item->data(0, Qt::UserRole).value<qulonglong>() ==999(qulonglong)selectThis) {1000tree->setCurrentItem(item);1001return;1002}1003}1004}1005}10061007void ObjectBrowser::boundaryUnifiedSlot() {1008updateBodyProperties();1009updateBoundaryProperties();1010}1011void ObjectBrowser::boundaryDividedSlot(double d) {1012bodyPropertyParentTreeItem->setExpanded(false);1013bodyPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy1014boundaryPropertyParentTreeItem->setExpanded(false);1015boundaryPropertyParentTreeItem->addChild(new QTreeWidgetItem()); // dummy1016}10171018void ObjectBrowser::boundarySelectedSlot(list_t *l, Qt::KeyboardModifiers modifiers) {10191020bodyPropertyParentTreeItem->setExpanded(true);1021boundaryPropertyParentTreeItem->setExpanded(true);10221023MainWindow *mainwindow = (MainWindow *)mainWindow;1024QDialog *dialog = NULL;10251026if (mainwindow->bodyEditActive &&1027mainwindow->glWidget->currentlySelectedBody != -1) {1028int m = mainwindow->glWidget->bodyMap.value(1029mainwindow->glWidget->currentlySelectedBody);1030dialog = (QDialog *)mainwindow->bodyPropertyEditor[m];1031} else {10321033for (int i = 0; i < mainwindow->glWidget->boundaryMap.count(); i++) {1034int n = mainwindow->glWidget->boundaryMap.key(i);1035if (n >= 0) {1036int m = mainwindow->glWidget->boundaryMap.value(n);1037if (m >= 0 && m < mainwindow->boundaryPropertyEditor.size() &&1038mainwindow->boundaryPropertyEditor[m] != NULL &&1039boundaryList(n) == l) {1040dialog = mainwindow->boundaryPropertyEditor[m];1041}1042}1043}10441045if (dialog == NULL) {1046for (int i = 0; i < mainwindow->glWidget->bodyMap.count(); i++) {1047int n = mainwindow->glWidget->bodyMap.key(i);1048if (n >= 0) {1049int m = mainwindow->glWidget->bodyMap.value(n);1050if (m >= 0 && m < mainwindow->bodyPropertyEditor.size() &&1051mainwindow->bodyPropertyEditor[m] != NULL && bodyList(n) == l) {1052dialog = mainwindow->bodyPropertyEditor[m];1053}1054}1055}1056}1057}10581059if (dialog == NULL) {1060cout << " could not find selected body/boundary in "1061"ObjectBrowser::boundarySelectedSlot(list_t*, Qt::KeyboardModifiers). list_t:"1062<< (qulonglong)l << endl;1063return;1064}10651066for (int i = 0; i < boundaryPropertyParentTreeItem->childCount(); i++) {1067QTreeWidgetItem *child = boundaryPropertyParentTreeItem->child(i);1068if (child->data(0, Qt::UserRole) == (qulonglong)dialog) {1069if( !(modifiers & Qt::ControlModifier) )tree->setCurrentItem(child);1070BoundaryPropertyEditor *pe = (BoundaryPropertyEditor *)dialog;1071connect1(1072pe, SIGNAL(BoundaryComboChanged(BoundaryPropertyEditor *, QString)),1073this, SLOT(boundaryComboChanged(BoundaryPropertyEditor *, QString)));1074connect1(pe->ui.applyButton, SIGNAL(clicked(bool)), this,1075SLOT(boundaryPropertyEditorAccepted(bool)));1076connect1(pe->ui.discardButton, SIGNAL(clicked(bool)), this,1077SLOT(boundaryPropertyEditorDiscarded(bool)));1078return;1079}1080}10811082for (int i = 0; i < bodyPropertyParentTreeItem->childCount(); i++) {1083QTreeWidgetItem *child = bodyPropertyParentTreeItem->child(i);1084if (child->data(0, Qt::UserRole) == (qulonglong)dialog) {1085if( !(modifiers & Qt::ControlModifier)) tree->setCurrentItem(child);1086BodyPropertyEditor *pe = (BodyPropertyEditor *)dialog;1087connect1(pe,1088SIGNAL(BodyMaterialComboChanged(BodyPropertyEditor *, QString)),1089this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));1090connect1(pe,1091SIGNAL(BodyInitialComboChanged(BodyPropertyEditor *, QString)),1092this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));1093connect1(pe, SIGNAL(BodyForceComboChanged(BodyPropertyEditor *, QString)),1094this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));1095connect1(pe,1096SIGNAL(BodyEquationComboChanged(BodyPropertyEditor *, QString)),1097this, SLOT(bodyComboChanged(BodyPropertyEditor *, QString)));1098connect1(pe->ui.applyButton, SIGNAL(clicked(bool)), this,1099SLOT(bodyPropertyEditorAccepted(bool)));1100connect1(pe->ui.discardButton, SIGNAL(clicked(bool)), this,1101SLOT(bodyPropertyEditorDiscarded(bool)));1102return;1103}1104}1105}11061107list_t *ObjectBrowser::boundaryList(int index) {11081109MainWindow *mainwindow = (MainWindow *)mainWindow;11101111int n = mainwindow->glWidget->getLists();1112int boundaryCount = 0;1113for (int i = 0; i < n; i++) {1114list_t *l = mainwindow->glWidget->getList(i);1115if (l->getNature() == PDE_BOUNDARY && l->getIndex() == index)1116return l;1117}1118return NULL;1119}11201121list_t *ObjectBrowser::selectBoundary(BoundaryPropertyEditor *pe_in_tree,1122bool append /*=false*/,1123bool select /*=true*/) {11241125MainWindow *mainwindow = (MainWindow *)mainWindow;1126if (mainwindow->glWidget->getMesh() == NULL)1127return NULL;11281129// unselect all the bodies1130for (int i = 0; i < mainwindow->glWidget->bodyMap.count(); i++) {1131int n = mainwindow->glWidget->bodyMap.key(i);1132if (n >= 0 && bodyList(n) != NULL)1133bodyList(n)->setSelected(false);1134if (bodyList(n) == NULL) {1135// cout << " *** bodyList(" << n << ") is NULL" <<1136// endl; cout << " *** body index is " <<1137// mainwindow->glWidget->bodyMap.value(i) << endl;1138}1139}11401141list_t *l = NULL;1142list_t *l_selected = NULL;1143// select boundary1144for (int i = 0; i < mainwindow->glWidget->boundaryMap.count(); i++) {1145int n = mainwindow->glWidget->boundaryMap.key(i);1146if (n >= 0) {1147int m = mainwindow->glWidget->boundaryMap.value(n);1148if (m >= 0 && m < mainwindow->boundaryPropertyEditor.size() &&1149mainwindow->boundaryPropertyEditor[m] != NULL) {1150BoundaryPropertyEditor *pe = mainwindow->boundaryPropertyEditor[m];1151l = boundaryList(n);1152if (l != NULL /*&& pe_in_tree != NULL*/) {1153if (pe == pe_in_tree) {1154l->setSelected(select);1155l_selected = l;1156}1157if (pe != pe_in_tree && append == false) {1158l->setSelected(!select);1159}1160}1161}1162}1163}11641165if (!append) {1166mainwindow->glWidget->rebuildEdgeLists();1167mainwindow->glWidget->rebuildSurfaceLists();1168mainwindow->glWidget->updateGL();1169}1170return l_selected;1171}11721173list_t *ObjectBrowser::selectBody(BodyPropertyEditor *pe_in_tree,1174bool append /*=false*/,1175bool select /*=true*/) {11761177MainWindow *mainwindow = (MainWindow *)mainWindow;1178if (mainwindow->glWidget->getMesh() == NULL)1179return NULL;11801181// unselect all the boundaries1182if (!append) {1183for (int i = 0; i < mainwindow->glWidget->boundaryMap.count(); i++) {1184int n = mainwindow->glWidget->boundaryMap.key(i);1185if (n >= 0 && boundaryList(n) != NULL)1186boundaryList(n)->setSelected(false);1187if (boundaryList(n) == NULL)1188cout << " *** boundaryList(" << n << ") is NULL" << endl;1189}1190}1191mainwindow->glWidget->currentlySelectedBody = -1;11921193list_t *l = NULL;1194list_t *l_selected = NULL;11951196// select body1197for (int i = 0; i < mainwindow->glWidget->bodyMap.count(); i++) {1198int n = mainwindow->glWidget->bodyMap.key(i);1199if (n >= 0) {1200int m = mainwindow->glWidget->bodyMap.value(n);1201if (m >= 0 && m < mainwindow->bodyPropertyEditor.size() &&1202mainwindow->bodyPropertyEditor[m] != NULL) {1203BodyPropertyEditor *pe = mainwindow->bodyPropertyEditor[m];1204l = bodyList(n);12051206// new1207if (l != NULL /*&& pe_in_tree != NULL*/) {1208if (pe == pe_in_tree) {1209l->setSelected(select);1210l_selected = l;1211mainwindow->glWidget->currentlySelectedBody = select ? n : -1;1212}1213if (pe != pe_in_tree && append == false) {1214l->setSelected(!select);1215}1216}12171218// oled1219// if(l != NULL)l->setSelected(/*pe_in_tree != NULL &&*/ pe ==1220// pe_in_tree); if(l != NULL /*&& pe_in_tree != NULL*/ && pe ==1221// pe_in_tree){ l_selected = l;1222}1223}1224}12251226if (l_selected == NULL) {1227// For 3D geometry1228mainwindow->glWidget->currentlySelectedBody = -1;1229int index_selected = -1;1230if (l_selected == NULL) {1231for (int i = 0; i < mainwindow->glWidget->boundaryMap.count(); i++) {1232int n = mainwindow->glWidget->boundaryMap.key(i);1233if (n >= 0) {1234int m = mainwindow->glWidget->boundaryMap.value(n);1235if (m >= 0 && m < mainwindow->boundaryPropertyEditor.size() &&1236mainwindow->boundaryPropertyEditor[m] != NULL) {1237BoundaryPropertyEditor *pe = mainwindow->boundaryPropertyEditor[m];1238l = boundaryList(n);1239if (l != NULL /*&& pe_in_tree != NULL*/) {1240int index = boundaryListToBodyIndex(l);1241if (index >= 0) {1242int m2 = mainwindow->glWidget->bodyMap.value(index);1243if (m2 >= 0 && m2 < mainwindow->bodyPropertyEditor.size() &&1244mainwindow->bodyPropertyEditor[m2] != NULL) {1245BodyPropertyEditor *bpe = mainwindow->bodyPropertyEditor[m2];1246if (bpe == pe_in_tree) {1247l_selected = l;1248l = selectBoundary(pe, true, select);1249index_selected = index;1250}1251}1252}1253}1254}1255}1256}1257mainwindow->glWidget->currentlySelectedBody =1258select ? index_selected : -1;1259}1260}12611262if (!append) {1263mainwindow->glWidget->rebuildEdgeLists();1264mainwindow->glWidget->rebuildSurfaceLists();1265mainwindow->glWidget->updateGL();1266}1267return l_selected;1268}12691270int ObjectBrowser::boundaryListToBodyIndex(list_t *l) {12711272MainWindow *mainwindow = (MainWindow *)mainWindow;1273mesh_t *mesh = mainwindow->glWidget->getMesh();1274int ret = -1;12751276if (true) {1277// determine the max bulk index1278int MAX_BULK_INDEX = -1;12791280for (int i = 0; i < mesh->getElements(); i++) {1281element_t *elem = mesh->getElement(i);1282if (elem->getNature() != PDE_BULK)1283break;1284if (elem->getIndex() > MAX_BULK_INDEX)1285MAX_BULK_INDEX = elem->getIndex();1286}12871288for (int i = 0; i < mesh->getSurfaces(); i++) {1289surface_t *surf = mesh->getSurface(i);1290if (surf->getNature() != PDE_BULK)1291break;1292if (surf->getIndex() > MAX_BULK_INDEX)1293MAX_BULK_INDEX = surf->getIndex();1294}12951296for (int i = 0; i < mesh->getEdges(); i++) {1297edge_t *edge = mesh->getEdge(i);1298if (edge->getNature() != PDE_BULK)1299break;1300if (edge->getIndex() > MAX_BULK_INDEX)1301MAX_BULK_INDEX = edge->getIndex();1302}13031304MAX_BULK_INDEX++;1305if (MAX_BULK_INDEX == 0) {1306cout << "Error in body selection: "1307"There are no legal body indices from which to choose"1308<< endl;1309cout.flush();1310goto body_selection_finished;1311}13121313// allocate temp arrays:1314bool *tmp1 = new bool[MAX_BULK_INDEX];1315bool *tmp2 = new bool[MAX_BULK_INDEX];13161317for (int i = 0; i < MAX_BULK_INDEX; i++) {1318tmp1[i] = true;1319tmp2[i] = false;1320}13211322// check if the selected lists uniquely determine a bulk body:1323for (int i = 0; i < mainwindow->glWidget->getLists(); i++) {1324list_t *l2 = mainwindow->glWidget->getList(i);13251326if (l2 == l &&1327(l2->getNature() == PDE_BULK)) { //:-) if(l2->isSelected() &&1328//(l2->getNature() == PDE_BULK)) {1329for (int j = 0; j < MAX_BULK_INDEX; j++) {1330if (j != l2->getIndex())1331tmp1[j] = false;1332}1333}13341335if (l2 == l &&1336(l2->getNature() ==1337PDE_BOUNDARY) && //:-) if(l2->isSelected() && (l2->getNature()1338//== PDE_BOUNDARY) &&1339(l2->getType() == SURFACELIST)) {1340for (int j = 0; j < mesh->getSurfaces(); j++) {1341surface_t *surf = mesh->getSurface(j);1342if (surf->getIndex() == l2->getIndex()) {1343for (int k = 0; k < surf->getElements(); k++) {1344int l = surf->getElementIndex(k);1345if (l < 0)1346break;1347element_t *elem = mesh->getElement(l);1348if ((elem->getIndex() < 0) ||1349(elem->getIndex() >= MAX_BULK_INDEX))1350break;1351tmp2[elem->getIndex()] = true;1352}1353for (int k = 0; k < MAX_BULK_INDEX; k++) {1354tmp1[k] &= tmp2[k];1355tmp2[k] = false;1356}1357}1358}1359}1360}13611362// array "tmp1" should contain only one entry with value "true"1363int count = 0;1364int found = -1;1365for (int i = 0; i < MAX_BULK_INDEX; i++) {1366if (tmp1[i]) {1367count++;1368found = i;1369}1370}13711372if ((count == 1) && (found >= 0)) {1373mainwindow->glWidget->currentlySelectedBody = found;1374ret = found;1375// cout << "*****boundary found: " << found << endl;1376}else{1377ret = mainwindow->glWidget->mostVisibleBody(MAX_BULK_INDEX, tmp1);1378}1379delete[] tmp1;1380delete[] tmp2;1381}1382body_selection_finished:13831384// Emit result to mainwindow:1385// emit(signalBoundarySelected(l));13861387return ret;1388}13891390void ObjectBrowser::updateBodyProperties(1391BodyPropertyEditor *selectThis /*=NULL*/) {13921393MainWindow *mainwindow = (MainWindow *)mainWindow;1394if (tree->currentItem() != NULL &&1395tree->currentItem()->parent() == bodyPropertyParentTreeItem) {1396tree->setCurrentItem(bodyPropertyParentTreeItem); // to improve speed1397}1398QTreeWidgetItem *treeItem = 0;1399while (treeItem = bodyPropertyParentTreeItem->takeChild(0))1400delete treeItem;14011402int count = 1;14031404QMapIterator<int, int> itr(mainwindow->glWidget->bodyMap);1405while (itr.hasNext()) {1406itr.next();1407int n = itr.key();1408if (n >= 0) {1409int m = itr.value();14101411if (m >= mainwindow->bodyPropertyEditor.size())1412mainwindow->bodyPropertyEditor.resize(m + 1);14131414if (!mainwindow->bodyPropertyEditor[m])1415mainwindow->bodyPropertyEditor[m] = new BodyPropertyEditor;14161417BodyPropertyEditor *pe = mainwindow->bodyPropertyEditor[m];14181419treeItem = new QTreeWidgetItem();1420bodyPropertyParentTreeItem->addChild(treeItem);1421QString title = pe->ui.nameEdit->text().trimmed();1422if (title.isEmpty()) {1423title = "Body Property " + QString::number(n);1424}14251426if (!pe->touched) {1427treeItem->setText(0, title);1428if (pe->equation || pe->material || pe->force || pe->initial)1429treeItem->setText(1, "<Canceled>");1430} else {1431QString sifbody = "Body " + QString::number(count++);1432QString sifname = title;1433if (pe->ui.nameEdit->text().trimmed().isEmpty()) {1434sifname = sifbody;1435}1436treeItem->setText(0, title);1437// treeItem->setText(1, "<" + sifbody + " \"" + sifname +"\">");1438treeItem->setText(1, sifbody + " in sif");1439}14401441treeItem->setData(0, Qt::UserRole, QVariant::fromValue((qulonglong)pe));14421443if (pe->equation != 0) {1444QTreeWidgetItem *child = new QTreeWidgetItem();1445treeItem->addChild(child);1446child->setText(0, "Equation");1447child->setText(1, pe->equation->nameEdit->text().trimmed());1448child->setData(1, Qt::UserRole,1449QVariant::fromValue((qulonglong)pe->equation));1450}1451if (pe->material != 0) {1452QTreeWidgetItem *child = new QTreeWidgetItem();1453treeItem->addChild(child);1454child->setText(0, "Material");1455child->setText(1, pe->material->nameEdit->text().trimmed());1456child->setData(1, Qt::UserRole,1457QVariant::fromValue((qulonglong)pe->material));1458}1459if (pe->force != 0) {1460QTreeWidgetItem *child = new QTreeWidgetItem();1461treeItem->addChild(child);1462child->setText(0, "Body force");1463child->setText(1, pe->force->nameEdit->text().trimmed());1464child->setData(1, Qt::UserRole,1465QVariant::fromValue((qulonglong)pe->force));1466}1467if (pe->initial != 0) {1468QTreeWidgetItem *child = new QTreeWidgetItem();1469treeItem->addChild(child);1470child->setText(0, "Initial condition");1471child->setText(1, pe->initial->nameEdit->text().trimmed());1472child->setData(1, Qt::UserRole,1473QVariant::fromValue((qulonglong)pe->initial));1474}1475treeItem->setExpanded(true);1476}1477}14781479if (selectThis != NULL) {1480QTreeWidgetItem *item;1481for (int i = 0; i < bodyPropertyParentTreeItem->childCount(); i++) {1482item = bodyPropertyParentTreeItem->child(i);1483if (item->data(0, Qt::UserRole).value<qulonglong>() ==1484(qulonglong)selectThis) {1485tree->setCurrentItem(item);1486return;1487}1488}1489}14901491/*1492cout << "solverparametereditor:" << mainwindow->solverParameterEditor.size()1493<< endl; for(int i= 0; i < mainwindow->solverParameterEditor.size(); i++){1494if(mainwindow->solverParameterEditor.at(i)) mainwindow->logMessage(1495mainwindow->solverParameterEditor.at(i)->solverName ); else cout << "null" <<1496endl;1497}1498*/1499}15001501list_t *ObjectBrowser::bodyList(int index) {15021503MainWindow *mainwindow = (MainWindow *)mainWindow;15041505int n = mainwindow->glWidget->getLists();1506int bodyCount = 0;1507for (int i = 0; i < n; i++) {1508list_t *l = mainwindow->glWidget->getList(i);1509if (l->getNature() == PDE_BULK && l->getIndex() == index)1510return l;1511}1512return NULL;1513}15141515void ObjectBrowser::snap(QWidget *widget) {1516// widget->move(mapToGlobal(QPoint(width(),0)));1517}15181519void ObjectBrowser::updateEquation() {1520tree->setCurrentItem(equationParentTreeItem);1521QTreeWidgetItem *treeItem;1522while (treeItem = equationParentTreeItem->takeChild(0))1523delete treeItem;1524MainWindow *mainwindow = (MainWindow *)mainWindow;1525int n = mainwindow->equationEditor.size();1526for (int i = 0; i < n; i++) {1527addToTree(mainwindow->equationEditor.at(i));1528}1529}1530void ObjectBrowser::updateMaterial() {1531tree->setCurrentItem(materialParentTreeItem);1532QTreeWidgetItem *treeItem;1533while (treeItem = materialParentTreeItem->takeChild(0))1534delete treeItem;1535MainWindow *mainwindow = (MainWindow *)mainWindow;1536int n = mainwindow->materialEditor.size();1537for (int i = 0; i < n; i++) {1538addToTree(mainwindow->materialEditor.at(i));1539}1540}1541void ObjectBrowser::updateBodyForce() {1542tree->setCurrentItem(bodyForceParentTreeItem);1543QTreeWidgetItem *treeItem;1544while (treeItem = bodyForceParentTreeItem->takeChild(0))1545delete treeItem;1546MainWindow *mainwindow = (MainWindow *)mainWindow;1547int n = mainwindow->bodyForceEditor.size();1548for (int i = 0; i < n; i++) {1549addToTree(mainwindow->bodyForceEditor.at(i));1550}1551}1552void ObjectBrowser::updateInitialCondition() {1553tree->setCurrentItem(initialConditionParentTreeItem);1554QTreeWidgetItem *treeItem;1555while (treeItem = initialConditionParentTreeItem->takeChild(0))1556delete treeItem;1557MainWindow *mainwindow = (MainWindow *)mainWindow;1558int n = mainwindow->initialConditionEditor.size();1559for (int i = 0; i < n; i++) {1560addToTree(mainwindow->initialConditionEditor.at(i));1561}1562}1563void ObjectBrowser::updateBoundaryCondition() {1564tree->setCurrentItem(boundaryConditionParentTreeItem);1565QTreeWidgetItem *treeItem;1566while (treeItem = boundaryConditionParentTreeItem->takeChild(0))1567delete treeItem;1568MainWindow *mainwindow = (MainWindow *)mainWindow;1569int n = mainwindow->boundaryConditionEditor.size();1570for (int i = 0; i < n; i++) {1571addToTree(mainwindow->boundaryConditionEditor.at(i));1572}1573}1574void ObjectBrowser::boundaryComboChanged(BoundaryPropertyEditor *pe,1575QString text) {1576QTreeWidgetItem *treeItem;15771578int n = boundaryPropertyParentTreeItem->childCount();1579for (int i = 0; i < n; i++) {1580treeItem = boundaryPropertyParentTreeItem->child(i);1581if (treeItem->data(0, Qt::UserRole) == (qulonglong)pe) {1582if (pe->condition != 0) {1583treeItem->setText(1, pe->condition->nameEdit->text().trimmed());1584} else {1585treeItem->setText(1, "");1586}1587treeItem->setData(1, Qt::UserRole,1588QVariant::fromValue((qulonglong)pe->condition));1589return;1590}1591}1592}15931594void ObjectBrowser::bodyComboChanged(BodyPropertyEditor *pe, QString text) {1595MainWindow *mainwindow = (MainWindow *)mainWindow;1596QTreeWidgetItem *treeItem;1597QTreeWidgetItem *child;1598int n = bodyPropertyParentTreeItem->childCount();1599for (int i = 0; i < n; i++) {1600treeItem = bodyPropertyParentTreeItem->child(i);1601if (treeItem->data(0, Qt::UserRole) == (qulonglong)pe) {1602while (child = treeItem->takeChild(0))1603delete child;16041605if (pe->equation != 0) {1606child = new QTreeWidgetItem();1607treeItem->addChild(child);1608child->setText(0, "Equation");1609child->setText(1, pe->equation->nameEdit->text().trimmed());1610child->setData(1, Qt::UserRole,1611QVariant::fromValue((qulonglong)pe->equation));1612}16131614if (pe->material != 0) {1615child = new QTreeWidgetItem();1616treeItem->addChild(child);1617child->setText(0, "Material");1618child->setText(1, pe->material->nameEdit->text().trimmed());1619child->setData(1, Qt::UserRole,1620QVariant::fromValue((qulonglong)pe->material));1621}16221623if (pe->force != 0) {1624child = new QTreeWidgetItem();1625treeItem->addChild(child);1626child->setText(0, "Body force");1627child->setText(1, pe->force->nameEdit->text().trimmed());1628child->setData(1, Qt::UserRole,1629QVariant::fromValue((qulonglong)pe->force));1630}16311632if (pe->initial != 0) {1633child = new QTreeWidgetItem();1634treeItem->addChild(child);1635child->setText(0, "Initial condition");1636child->setText(1, pe->initial->nameEdit->text().trimmed());1637child->setData(1, Qt::UserRole,1638QVariant::fromValue((qulonglong)pe->initial));1639}16401641return;1642}1643}1644}16451646void ObjectBrowser::selectTreeItemByID(QTreeWidgetItem *parent, int id) {1647DynamicEditor *de;1648if (id >= 0) {1649for (int i = 0; i < parent->childCount(); i++) {1650de = (DynamicEditor *)parent->child(i)1651->data(0, Qt::UserRole)1652.value<qulonglong>();1653if (de == NULL)1654cout << "*** de==NULL" << endl;1655if (de != NULL && de->ID == id) {1656tree->setCurrentItem(parent->child(i));1657return;1658}1659}1660}1661tree->setCurrentItem(parent);1662}16631664void ObjectBrowser::bodyPropertyEditorAccepted(bool checked) {1665QWidget *a = (QWidget *)QObject::sender();1666updateBodyProperties((BodyPropertyEditor *)a->parent());1667}16681669void ObjectBrowser::bodyPropertyEditorDiscarded(bool checked) {1670QWidget *a = (QWidget *)QObject::sender();1671updateBodyProperties((BodyPropertyEditor *)a->parent());1672}1673void ObjectBrowser::boundaryPropertyEditorAccepted(bool checked) {1674QWidget *a = (QWidget *)QObject::sender();1675updateBoundaryProperties((BoundaryPropertyEditor *)a->parent());1676}1677void ObjectBrowser::boundaryPropertyEditorDiscarded(bool checked) {1678QWidget *a = (QWidget *)QObject::sender();1679updateBoundaryProperties((BoundaryPropertyEditor *)a->parent());1680}16811682void ObjectBrowser::viewFullScreenSlot() {1683if (isVisible())1684hide();1685else1686show();1687}16881689void ObjectBrowser::viewNormalModeSlot() { show(); }16901691bool ObjectBrowser::connect1(const QObject *sender, const char *signal,1692const QObject *receiver, const char *method,1693Qt::ConnectionType type /*= Qt::AutoConnection*/) {1694disconnect(sender, signal, receiver, method);1695return connect(sender, signal, receiver, method, type);1696}16971698void ObjectBrowser::bodyCheckBoxChangedSlot(int state) {1699updateBodyProperties();17001701QWidget *a = (QWidget *)QObject::sender();1702if (a == NULL)1703return;1704BodyPropertyEditor *pe =1705(BodyPropertyEditor *)a->property("body").toULongLong();1706if (pe == NULL)1707return;17081709selectBody(pe, true, state == Qt::Checked);1710MainWindow *mainwindow = (MainWindow *)mainWindow;1711mainwindow->glWidget->rebuildEdgeLists();1712mainwindow->glWidget->rebuildSurfaceLists();1713mainwindow->glWidget->updateGL();1714}17151716void ObjectBrowser::boundaryCheckBoxChangedSlot(int state) {1717updateBoundaryProperties();17181719QWidget *a = (QWidget *)QObject::sender();1720if (a == NULL)1721return;1722BoundaryPropertyEditor *pe =1723(BoundaryPropertyEditor *)a->property("boundary").toULongLong();1724if (pe == NULL)1725return;17261727selectBoundary(pe, true, state == Qt::Checked);1728MainWindow *mainwindow = (MainWindow *)mainWindow;1729mainwindow->glWidget->rebuildEdgeLists();1730mainwindow->glWidget->rebuildSurfaceLists();1731mainwindow->glWidget->updateGL();1732}17331734void ObjectBrowser::treeItemSelectionChangedSlot() {1735/*1736if(item == bodyPropertyParentTreeItem){1737updateBodyProperties();1738return;1739}1740if(item == boundaryPropertyParentTreeItem){1741updateBoundaryProperties();1742return;1743}1744*/17451746MainWindow *mainwindow = (MainWindow *)mainWindow;1747if (mainwindow->glWidget->getMesh() == NULL)1748return;17491750QTreeWidgetItem *item = tree->currentItem();17511752// select boundaries/bodies checked in DyanmicEditor1753if (item->parent() == equationParentTreeItem) {1754updateBodyProperties();1755updateBoundaryProperties();1756DynamicEditor *pe =1757(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();1758mainwindow->createBodyCheckBoxes(BODY_EQUATION, pe);1759QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();1760selectBody(NULL);1761for (int i = 2; i < box->children().size(); i++) {1762QCheckBox *cb = (QCheckBox *)box->children()[i];1763connect1(cb, SIGNAL(stateChanged(int)), this,1764SLOT(bodyCheckBoxChangedSlot(int)));1765if (cb->isChecked() && i - 2 < mainwindow->bodyPropertyEditor.size()) {1766selectBody(mainwindow->bodyPropertyEditor[i - 2], true);1767}1768}1769mainwindow->glWidget->rebuildEdgeLists();1770mainwindow->glWidget->rebuildSurfaceLists();1771mainwindow->glWidget->updateGL();1772return;1773}1774if (item->parent() == materialParentTreeItem) {1775updateBodyProperties();1776updateBoundaryProperties();1777DynamicEditor *pe =1778(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();1779mainwindow->createBodyCheckBoxes(BODY_MATERIAL, pe);1780QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();1781selectBody(NULL);1782for (int i = 2; i < box->children().size(); i++) {1783QCheckBox *cb = (QCheckBox *)box->children()[i];1784connect1(cb, SIGNAL(stateChanged(int)), this,1785SLOT(bodyCheckBoxChangedSlot(int)));1786if (cb->isChecked())1787selectBody(1788(BodyPropertyEditor *)bodyPropertyParentTreeItem->child(i - 2)1789->data(0, Qt::UserRole)1790.value<qulonglong>(),1791true);1792}1793mainwindow->glWidget->rebuildEdgeLists();1794mainwindow->glWidget->rebuildSurfaceLists();1795mainwindow->glWidget->updateGL();1796return;1797}1798if (item->parent() == bodyForceParentTreeItem) {1799updateBodyProperties();1800updateBoundaryProperties();1801DynamicEditor *pe =1802(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();1803mainwindow->createBodyCheckBoxes(BODY_FORCE, pe);1804QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();1805selectBody(NULL);1806for (int i = 2; i < box->children().size(); i++) {1807QCheckBox *cb = (QCheckBox *)box->children()[i];1808connect1(cb, SIGNAL(stateChanged(int)), this,1809SLOT(bodyCheckBoxChangedSlot(int)));1810if (cb->isChecked())1811selectBody(1812(BodyPropertyEditor *)bodyPropertyParentTreeItem->child(i - 2)1813->data(0, Qt::UserRole)1814.value<qulonglong>(),1815true);1816}1817mainwindow->glWidget->rebuildEdgeLists();1818mainwindow->glWidget->rebuildSurfaceLists();1819mainwindow->glWidget->updateGL();1820return;1821}1822if (item->parent() == initialConditionParentTreeItem) {1823updateBodyProperties();1824updateBoundaryProperties();1825DynamicEditor *pe =1826(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();1827mainwindow->createBodyCheckBoxes(BODY_INITIAL, pe);1828QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();1829selectBody(NULL);1830for (int i = 2; i < box->children().size(); i++) {1831QCheckBox *cb = (QCheckBox *)box->children()[i];1832connect1(cb, SIGNAL(stateChanged(int)), this,1833SLOT(bodyCheckBoxChangedSlot(int)));1834if (cb->isChecked())1835selectBody(1836(BodyPropertyEditor *)bodyPropertyParentTreeItem->child(i - 2)1837->data(0, Qt::UserRole)1838.value<qulonglong>(),1839true);1840}1841mainwindow->glWidget->rebuildEdgeLists();1842mainwindow->glWidget->rebuildSurfaceLists();1843mainwindow->glWidget->updateGL();1844return;1845}1846if (item->parent() == boundaryConditionParentTreeItem) {1847updateBodyProperties();1848updateBoundaryProperties();1849DynamicEditor *pe =1850(DynamicEditor *)item->data(0, Qt::UserRole).value<qulonglong>();1851mainwindow->createBoundaryCheckBoxes(pe);1852QGroupBox *box = (QGroupBox *)pe->spareScroll->widget();1853selectBoundary(NULL);1854for (int i = 2; i < box->children().size(); i++) {1855QCheckBox *cb = (QCheckBox *)box->children()[i];1856connect1(cb, SIGNAL(stateChanged(int)), this,1857SLOT(boundaryCheckBoxChangedSlot(int)));1858if (cb->isChecked())1859selectBoundary((BoundaryPropertyEditor *)boundaryPropertyParentTreeItem1860->child(i - 2)1861->data(0, Qt::UserRole)1862.value<qulonglong>(),1863true);1864}1865mainwindow->glWidget->rebuildEdgeLists();1866mainwindow->glWidget->rebuildSurfaceLists();1867mainwindow->glWidget->updateGL();1868return;1869}18701871// select boundary/body1872if (item->parent() == boundaryPropertyParentTreeItem) {1873BoundaryPropertyEditor *pe =1874(BoundaryPropertyEditor *)item->data(0, Qt::UserRole)1875.value<qulonglong>();1876if (pe == NULL) {1877cout << " BoundaryPropertyEditor NULL" << endl;1878return;1879}1880selectBoundary(pe);1881return;1882}1883if (item->parent() != NULL &&1884item->parent()->parent() == boundaryPropertyParentTreeItem) {1885BoundaryPropertyEditor *pe = (BoundaryPropertyEditor *)item->parent()1886->data(0, Qt::UserRole)1887.value<qulonglong>();1888if (pe == NULL) {1889cout << " BoundaryPropertyEditor NULL" << endl;1890return;1891}1892selectBoundary(pe);1893return;1894}1895if (item->parent() == bodyPropertyParentTreeItem) {1896BodyPropertyEditor *pe =1897(BodyPropertyEditor *)item->data(0, Qt::UserRole).value<qulonglong>();1898if (pe == NULL) {1899cout << " BodyPropertyEditor NULL" << endl;1900return;1901}1902selectBody(pe);1903return;1904}1905if (item->parent() != NULL &&1906item->parent()->parent() == bodyPropertyParentTreeItem) {1907BodyPropertyEditor *pe = (BodyPropertyEditor *)item->parent()1908->data(0, Qt::UserRole)1909.value<qulonglong>();1910if (pe == NULL) {1911cout << " BodyPropertyEditor NULL" << endl;1912return;1913}1914selectBody(pe);1915return;1916}19171918selectBoundary(NULL);1919selectBody(NULL);1920}19211922void ObjectBrowser::meshingStartedSlot() {}1923void ObjectBrowser::meshingTerminatedSlot() {1924updateBodyProperties();1925updateBoundaryProperties();1926}1927void ObjectBrowser::meshingFinishedSlot() {1928updateBodyProperties();1929updateBoundaryProperties();1930}193119321933