Skip to content

Commit

Permalink
Reads Mesh nodes numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
LafCorentin committed Jul 23, 2020
1 parent 221aaf0 commit bad7de1
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
/CMakeLists.txt.user
*.autosave
1 change: 1 addition & 0 deletions src/plugins/editing/MappingView/CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ add_plugin(MappingView

src/mappingviewplugin.cpp
src/mappingviewwidget.cpp
src/meshreader.cpp
UIS
src/mappingviewwidget.ui
PLUGINS
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/editing/MappingView/i18n/MappingView_fr.ts
Expand Up @@ -41,9 +41,5 @@
<source>No</source>
<translation>Non</translation>
</message>
<message>
<source>VICTOOOOIIIIIRE</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
35 changes: 29 additions & 6 deletions src/plugins/editing/MappingView/src/mappingviewwidget.cpp
Expand Up @@ -24,7 +24,7 @@ along with this program. If not, see <https://gnu.org/licenses>.
#include "corecliutils.h"
#include "filemanager.h"
#include "mappingviewwidget.h"

#include "meshreader.h"
#include "cellmlfilemanager.h"

//==============================================================================
Expand All @@ -45,10 +45,13 @@ namespace MappingView {

MappingViewWidget::MappingViewWidget(QWidget *pParent) :
ViewWidget(pParent),
mGui(new Ui::MappingViewWidget)
mGui(new Ui::MappingViewWidget),
mListOutput(nullptr)
{
// Delete the layout that comes with ViewWidget

mOutputFileName = "../MeshFiles/MainTime_0.part0.exnode";

delete layout();

// Set up the GUI
Expand Down Expand Up @@ -112,14 +115,24 @@ void MappingViewWidget::update(const QString &pFileName)
mGui->sha1Value->setText(sha1Value.isEmpty()?"???":sha1Value);
mGui->sizeValue->setText(Core::sizeAsString(quint64(QFile(pFileName).size())));

mListViewModel= new QStringListModel(this); //TODO defining only when charging the plugin ?
mListViewModelVariables = new QStringListModel(); //TODO defining only when charging the plugin ?
mListViewModelOutput = new QStringListModel();

mGui->variablesList->setModel(mListViewModelVariables); //TODO set only when charging the plugin ?
mGui->outputList->setModel(mListViewModelOutput);
//TODO
//mGui->tableView->setModel()

mGui->variablesList->setModel(mListViewModel); //TODO set only when charging the plugin ?

//Retrieve The output variables

updateOutput();
mListViewModelOutput->setStringList(*mListOutput);

// Retrieve the requested CellML file

mCellmlFile = CellMLSupport::CellmlFileManager::instance()->cellmlFile(pFileName);
//TODO can be null

populateCellmlModel();
}

Expand Down Expand Up @@ -166,9 +179,19 @@ void MappingViewWidget::populateCellmlModel()
}
}

mListViewModel->setStringList(list);
mListViewModelVariables->setStringList(list);
}

void MappingViewWidget::updateOutput()
{
if (mListOutput != nullptr) {
delete mListOutput;
}

meshReader reader(mOutputFileName);

mListOutput = new QStringList(reader.getNodesNames());
}

//==============================================================================

Expand Down
14 changes: 11 additions & 3 deletions src/plugins/editing/MappingView/src/mappingviewwidget.h
Expand Up @@ -30,7 +30,8 @@ along with this program. If not, see <https://gnu.org/licenses>.

//==============================================================================

#include <QStringListModel>
#include <QStringListModel> //TODO remove when over
#include <QTableView>

//==============================================================================

Expand Down Expand Up @@ -64,12 +65,19 @@ class MappingViewWidget : public Core::ViewWidget

CellMLSupport::CellmlFile *mCellmlFile;

QStringListModel *mListViewModel;
QStringListModel
*mListViewModelVariables,//TODO temporary
*mListViewModelOutput;//TODO temporary

QString mFileName;
//QSqlRelationalTableModel *mTableModel;

QStringList *mListOutput;

QString mFileName;
QString mOutputFileName;
void populateCellmlModel();

void updateOutput();
};

//==============================================================================
Expand Down
12 changes: 9 additions & 3 deletions src/plugins/editing/MappingView/src/mappingviewwidget.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>404</width>
<height>409</height>
<width>681</width>
<height>773</height>
</rect>
</property>
<layout class="QFormLayout">
Expand Down Expand Up @@ -107,9 +107,15 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="4" column="1">
<widget class="QListView" name="variablesList"/>
</item>
<item row="6" column="1">
<widget class="QTableView" name="mappingTable"/>
</item>
<item row="5" column="1">
<widget class="QListView" name="outputList"/>
</item>
</layout>
</widget>
<resources/>
Expand Down
73 changes: 73 additions & 0 deletions src/plugins/editing/MappingView/src/meshreader.cpp
@@ -0,0 +1,73 @@
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://gnu.org/licenses>.
*******************************************************************************/

//==============================================================================
// Mesh file reader
//==============================================================================

#include "meshreader.h"

//==============================================================================

#include <QTextStream>

//==============================================================================

namespace OpenCOR {
namespace MappingView {

//==============================================================================

meshReader::meshReader(QString name):
pFileName(name)
{
}

//==============================================================================

QStringList meshReader::getNodesNames()
{
QStringList list = QStringList();

QFile file(pFileName);

if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return list;
}
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
QStringList words = line.split(' ');
words.removeAll("");
if (words.first()==QString("Node:")) {
list << words[1];
}
}

return list; //TODO sort before ?
}

//==============================================================================

} // namespace MappingView
} // namespace OpenCOR

//==============================================================================
// End of file
//==============================================================================
64 changes: 64 additions & 0 deletions src/plugins/editing/MappingView/src/meshreader.h
@@ -0,0 +1,64 @@
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://gnu.org/licenses>.
*******************************************************************************/

//==============================================================================
// Mesh file reader
//==============================================================================

#pragma once

#include <QFile>

//==============================================================================

namespace Ui {
class MappingViewWidget;
} // namespace Ui

//==============================================================================

namespace OpenCOR {
namespace MappingView {

//==============================================================================


class meshReader : public QObject
{
Q_OBJECT
public:

meshReader(QString);

QStringList getNodesNames();

private:
QString pFileName;

};

//==============================================================================

} // namespace MappingView
} // namespace OpenCOR

//==============================================================================
// End of file
//==============================================================================

0 comments on commit bad7de1

Please sign in to comment.