diff --git a/src/plugins/editing/MappingView/CMakeLists.txt b/src/plugins/editing/MappingView/CMakeLists.txt index 0ec124624e..3afaef01b9 100644 --- a/src/plugins/editing/MappingView/CMakeLists.txt +++ b/src/plugins/editing/MappingView/CMakeLists.txt @@ -15,6 +15,8 @@ add_plugin(MappingView src/mappingviewplugin.cpp src/mappingviewwidget.cpp src/mappingviewzincwidget.cpp + UIS + src/mappingviewwidget.ui PLUGINS Core CellMLSupport diff --git a/src/plugins/editing/MappingView/i18n/MappingView_fr.ts b/src/plugins/editing/MappingView/i18n/MappingView_fr.ts index 0dd22500d5..e523f29369 100644 --- a/src/plugins/editing/MappingView/i18n/MappingView_fr.ts +++ b/src/plugins/editing/MappingView/i18n/MappingView_fr.ts @@ -1,6 +1,17 @@ + + MappingViewWidget + + Node: + + + + Variable: + + + OpenCOR::MappingView::MappingViewPlugin diff --git a/src/plugins/editing/MappingView/src/mappingvieweditingwidget.cpp b/src/plugins/editing/MappingView/src/mappingvieweditingwidget.cpp index 56a9ebb45f..0a542bb3de 100644 --- a/src/plugins/editing/MappingView/src/mappingvieweditingwidget.cpp +++ b/src/plugins/editing/MappingView/src/mappingvieweditingwidget.cpp @@ -46,13 +46,16 @@ namespace MappingView { MappingViewEditingWidget::MappingViewEditingWidget(const QString &pFileName, const QString &pMeshFileName, QWidget *pParent) : - Core::SplitterWidget(pParent) + Core::SplitterWidget(pParent), + mMapMatch() { mCellmlFile = CellMLSupport::CellmlFileManager::instance()->cellmlFile(pFileName); mListViewModelVariables = new QStringListModel(); mListViewModelOutput = new QStringListModel(); + mTreeViewModel = new QStandardItemModel(this); + populateCellmlModel(); populateOutput(pMeshFileName); } @@ -87,6 +90,11 @@ QStringListModel* MappingViewEditingWidget::listViewModelOutput() return mListViewModelOutput; } +QStandardItemModel *MappingViewEditingWidget::getTreeViewModel() +{ + return mTreeViewModel; +} + //============================================================================== void MappingViewEditingWidget::filePermissionsChanged() @@ -95,6 +103,23 @@ void MappingViewEditingWidget::filePermissionsChanged() //============================================================================== +QString MappingViewEditingWidget::getVariableOfNode(int pNodeId) +{ + if (mMapMatch.contains(pNodeId)) { + return mMapMatch[pNodeId]; + } + return ""; +} + +//============================================================================== + +void MappingViewEditingWidget::AddVariableToNode(QString pVariable, int pNodeId) +{ + mMapMatch.insert(pNodeId,pVariable); +} + +//============================================================================== + void MappingViewEditingWidget::populateCellmlModel() { QStringList list; @@ -125,6 +150,10 @@ void MappingViewEditingWidget::populateCellmlModel() ObjRef componentVariables = component->variables(); if (componentVariables->length() != 0) { + + QStandardItem *componentItem = new QStandardItem(QString::fromStdWString(component->name())); + mTreeViewModel->invisibleRootItem()->appendRow(componentItem); + // Retrieve the model's component's variables themselves ObjRef componentVariablesIter = componentVariables->iterateVariables(); @@ -132,6 +161,9 @@ void MappingViewEditingWidget::populateCellmlModel() for (ObjRef componentVariable = componentVariablesIter->nextVariable(); componentVariable != nullptr; componentVariable = componentVariablesIter->nextVariable()) { + QStandardItem *variableItem = new QStandardItem(QString::fromStdWString(componentVariable->name())); + + componentItem->appendRow(variableItem); list.append(QString::fromStdWString(componentVariable->name())); } } diff --git a/src/plugins/editing/MappingView/src/mappingvieweditingwidget.h b/src/plugins/editing/MappingView/src/mappingvieweditingwidget.h index 955dc32e27..5bd7846837 100644 --- a/src/plugins/editing/MappingView/src/mappingvieweditingwidget.h +++ b/src/plugins/editing/MappingView/src/mappingvieweditingwidget.h @@ -33,6 +33,7 @@ along with this program. If not, see . #include //TODO remove when over #include +#include //============================================================================== @@ -65,12 +66,23 @@ class MappingViewEditingWidget : public Core::SplitterWidget QStringListModel *listViewModelOutput(); + QStandardItemModel *getTreeViewModel(); + void filePermissionsChanged(); + QString getVariableOfNode(int pNodeId); + + void AddVariableToNode(QString pVariable, int pNodeId); + private: CellMLSupport::CellmlFile *mCellmlFile; + //TODO : * or not ? + QMap mMapMatch; + + QStandardItemModel *mTreeViewModel; + QStringListModel *mListViewModelVariables = nullptr,//TODO temporary *mListViewModelOutput = nullptr;//TODO temporary diff --git a/src/plugins/editing/MappingView/src/mappingviewmeshreader.cpp b/src/plugins/editing/MappingView/src/mappingviewmeshreader.cpp index 780c1f77a9..8f12a54dde 100644 --- a/src/plugins/editing/MappingView/src/mappingviewmeshreader.cpp +++ b/src/plugins/editing/MappingView/src/mappingviewmeshreader.cpp @@ -34,8 +34,8 @@ namespace MappingView { //============================================================================== -MappingViewMeshReader::MappingViewMeshReader(QString name): - pFileName(name) +MappingViewMeshReader::MappingViewMeshReader(QString pName): + pFileName(pName) { } diff --git a/src/plugins/editing/MappingView/src/mappingviewmeshreader.h b/src/plugins/editing/MappingView/src/mappingviewmeshreader.h index e77b5d05c4..2205f6aaea 100644 --- a/src/plugins/editing/MappingView/src/mappingviewmeshreader.h +++ b/src/plugins/editing/MappingView/src/mappingviewmeshreader.h @@ -44,7 +44,7 @@ class MappingViewMeshReader : public QObject Q_OBJECT public: - MappingViewMeshReader(QString); + MappingViewMeshReader(QString pFileName); QStringList getNodesNames(); diff --git a/src/plugins/editing/MappingView/src/mappingviewwidget.cpp b/src/plugins/editing/MappingView/src/mappingviewwidget.cpp index 11f7a84c23..931fa55ca2 100644 --- a/src/plugins/editing/MappingView/src/mappingviewwidget.cpp +++ b/src/plugins/editing/MappingView/src/mappingviewwidget.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . #include "borderedwidget.h" #include "mappingviewwidget.h" #include "zincwidget.h" +#include "toolbarwidget.h" //============================================================================== @@ -52,26 +53,20 @@ namespace MappingView { MappingViewWidget::MappingViewWidget(QWidget *pParent) : Core::SplitterWidget(pParent), - mAxesFontPointSize(0) + mAxesFontPointSize(0), + mGui(new Ui::MappingViewWidget) { + // Set up the GUI + + mGui->setupUi(this); // Keep track of our movement /* connect(this, &Core::SplitterWidget::splitterMoved, this, &MappingViewEditingWidget::splitterMoved); */ - - // Set our orientation - - setOrientation(Qt::Vertical); - - - - - mListWidgetVariables = new QListWidget(); - mListWidgetOutput = new QListWidget(); - + //addWidget(mListWidgetVariables); //TODO @@ -82,10 +77,18 @@ MappingViewWidget::MappingViewWidget(QWidget *pParent) : mMappingViewZincWidget = new MappingViewZincWidget(this, mMeshFileName); //TODO move to mappingviewzincwidget and you know how it works - connect(mMappingViewZincWidget, SIGNAL(devicePixelRatioChanged(const int &)), - this, SLOT(devicePixelRatioChanged(const int &))); + connect(mMappingViewZincWidget, &MappingViewZincWidget::devicePixelRatioChanged, + this, &MappingViewWidget::devicePixelRatioChanged); + + connect(mMappingViewZincWidget, &MappingViewZincWidget::nodeSelection, + this, &MappingViewWidget::nodeSelection); + + mGui->layout->addWidget(mMappingViewZincWidget); + + //mToolBarWidget = new Core::ToolBarWidget(); + + - addWidget(mMappingViewZincWidget); } //============================================================================== @@ -124,6 +127,7 @@ void MappingViewWidget::initialize(const QString &pFileName) //mListWidgetVariables->setModel(mEditingWidget->listViewModelVariables()); //TODO set only when charging the plugin ? //mGui->outputList->setModel(mEditingWidget->listViewModelOutput()); + mGui->variableTree->setModel(mEditingWidget->getTreeViewModel()); } //============================================================================== @@ -215,6 +219,19 @@ void MappingViewWidget::devicePixelRatioChanged(const int &pDevicePixelRatio) //============================================================================== +void MappingViewWidget::nodeSelection(int pId) { + + if (pId==-1) { + mGui->nodeValue->setText(""); + mGui->variableValue->setText(""); + } else { + mGui->nodeValue->setNum(pId); + mGui->variableValue->setText(mEditingWidget->getVariableOfNode(pId)); + } +} + +//============================================================================== + } // namespace MappingView } // namespace OpenCOR diff --git a/src/plugins/editing/MappingView/src/mappingviewwidget.h b/src/plugins/editing/MappingView/src/mappingviewwidget.h index f15329e8c5..95f8ab89d4 100644 --- a/src/plugins/editing/MappingView/src/mappingviewwidget.h +++ b/src/plugins/editing/MappingView/src/mappingviewwidget.h @@ -49,6 +49,12 @@ namespace OpenCOR { //============================================================================== +namespace Core { + class ToolBarWidget; +} // namespace Core + +//============================================================================== + namespace ZincWidget { class ZincWidget; } // namespace ZincWidget @@ -82,6 +88,10 @@ class MappingViewWidget : public Core::SplitterWidget int mAxesFontPointSize; private: + Ui::MappingViewWidget *mGui; + + Core::ToolBarWidget *mToolBarWidget; + MappingViewZincWidget *mMappingViewZincWidget; QListWidget *mListWidgetVariables; @@ -94,6 +104,8 @@ class MappingViewWidget : public Core::SplitterWidget private slots: void devicePixelRatioChanged(const int &pDevicePixelRatio); + void nodeSelection(int pId); + }; diff --git a/src/plugins/editing/MappingView/src/mappingviewwidget.ui b/src/plugins/editing/MappingView/src/mappingviewwidget.ui index bc1352b87c..7c956c4872 100644 --- a/src/plugins/editing/MappingView/src/mappingviewwidget.ui +++ b/src/plugins/editing/MappingView/src/mappingviewwidget.ui @@ -7,114 +7,52 @@ 0 0 681 - 773 + 315 - - - - - 75 - true - - - - File name: - - - - - - - - - - - - - - - 75 - true - - - - Locked: - - - - - - - - - - - - - - - 75 - true - - - - SHA-1: - - - - - - - - - - - - - - - 75 - true - - - - Size: - - - - - - - - - - - - - - 75 - true - - - - false - - - Variables: - - - - - - - - - - - + + + + + + + + + Node: + + + + + + + + + + + + + + Variable: + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/editing/MappingView/src/mappingviewzincwidget.cpp b/src/plugins/editing/MappingView/src/mappingviewzincwidget.cpp index 310cda2e6a..a69be082dc 100644 --- a/src/plugins/editing/MappingView/src/mappingviewzincwidget.cpp +++ b/src/plugins/editing/MappingView/src/mappingviewzincwidget.cpp @@ -96,9 +96,12 @@ MappingViewZincWidget::MappingViewZincWidget(QWidget *pParent, const QString &pM OpenCMISS::Zinc::Scenefiltermodule sceneFilterModule = mScene->getScenefiltermodule(); OpenCMISS::Zinc::Scenefilter nodeFilter = sceneFilterModule.createScenefilterFieldDomainType(OpenCMISS::Zinc::Field::DOMAIN_TYPE_NODES); - mScenePicker->setScenefilter(nodeFilter); + // Allow for things to be dropped on us + + //TODO remove this ? + //setAcceptDrops(true); } //============================================================================== diff --git a/src/plugins/editing/MappingView/src/mappingviewzincwidget.h b/src/plugins/editing/MappingView/src/mappingviewzincwidget.h index c33420e781..402463cafe 100644 --- a/src/plugins/editing/MappingView/src/mappingviewzincwidget.h +++ b/src/plugins/editing/MappingView/src/mappingviewzincwidget.h @@ -87,7 +87,7 @@ class MappingViewZincWidget : public ZincWidget::ZincWidget void click(QMouseEvent *pEvent); signals: - void nodeSelection(int id); + void nodeSelection(int pId); };