Skip to content

Commit

Permalink
Added Zinc Widget
Browse files Browse the repository at this point in the history
do not display the previous lists etc but instead display an empty list and a transparent zinc widget
  • Loading branch information
LafCorentin committed Jul 27, 2020
1 parent 68b20c4 commit f7bdbe4
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 142 deletions.
5 changes: 3 additions & 2 deletions src/plugins/editing/MappingView/CMakeLists.txt
Expand Up @@ -10,13 +10,14 @@ add_plugin(MappingView
../../plugininterface.cpp
../../viewinterface.cpp

../../windowinterface.cpp

src/mappingvieweditingwidget.cpp
src/mappingviewplugin.cpp
src/mappingviewwidget.cpp
src/meshreader.cpp
UIS
src/mappingviewwidget.ui
PLUGINS
Core
CellMLSupport
ZincWidget
)
45 changes: 0 additions & 45 deletions src/plugins/editing/MappingView/i18n/MappingView_fr.ts
@@ -1,56 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="fr_FR" sourcelanguage="en_GB">
<context>
<name>MappingViewWidget</name>
<message>
<source>File name:</source>
<translation>Nom de fichier :</translation>
</message>
<message>
<source>Locked:</source>
<translation>Verrouillé :</translation>
</message>
<message>
<source>SHA-1:</source>
<translation>SHA-1 :</translation>
</message>
<message>
<source>Size:</source>
<translation>Taille :</translation>
</message>
<message>
<source>Variables:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OpenCOR::MappingView::MappingViewEditingWidget</name>
<message>
<source>Yes</source>
<translation type="unfinished">Oui</translation>
</message>
<message>
<source>No</source>
<translation type="unfinished">Non</translation>
</message>
</context>
<context>
<name>OpenCOR::MappingView::MappingViewPlugin</name>
<message>
<source>Mapping</source>
<translation>Mappeur</translation>
</message>
</context>
<context>
<name>OpenCOR::MappingView::MappingViewWidget</name>
<message>
<source>Yes</source>
<translation>Oui</translation>
</message>
<message>
<source>No</source>
<translation>Non</translation>
</message>
</context>
</TS>
Expand Up @@ -66,13 +66,11 @@ class MappingViewEditingWidget : public Core::SplitterWidget
void filePermissionsChanged();
private:

CellMLSupport::CellmlFile *mCellmlFile;
CellMLSupport::CellmlFile *mCellmlFile = nullptr;

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

//QSqlRelationalTableModel *mTableModel;
*mListViewModelVariables = nullptr,//TODO temporary
*mListViewModelOutput = nullptr;//TODO temporary

QString mFileName;
QString mOutputFileName;
Expand Down
149 changes: 63 additions & 86 deletions src/plugins/editing/MappingView/src/mappingviewwidget.cpp
Expand Up @@ -21,11 +21,13 @@ along with this program. If not, see <https://gnu.org/licenses>.
// Mapping view widget
//==============================================================================

#include "borderedwidget.h"
#include "corecliutils.h"
#include "filemanager.h"
#include "mappingviewwidget.h"
#include "meshreader.h"
#include "cellmlfilemanager.h"
#include "zincwidget.h"

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

Expand All @@ -38,42 +40,66 @@ along with this program. If not, see <https://gnu.org/licenses>.

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

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

namespace OpenCOR {
namespace MappingView {

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

MappingViewWidget::MappingViewWidget(QWidget *pParent) :
ViewWidget(pParent),
mGui(new Ui::MappingViewWidget)
Core::SplitterWidget(pParent),
mAxesFontPointSize(0),
mZincContext(nullptr)//,
// mZincSceneViewerDescription(nullptr)
{
// Delete the layout that comes with ViewWidget
// Set our orientation

setOrientation(Qt::Horizontal);

// Keep track of our movement
/*
connect(this, &Core::SplitterWidget::splitterMoved,
this, &MappingViewEditingWidget::splitterMoved);
*/

mListWidgetVariables = new QListWidget();
mListWidgetOutput = new QListWidget();

addWidget(mListWidgetVariables);

// Create and add a Zinc widget

delete layout();
mZincWidget = new ZincWidget::ZincWidget(this);

// Set up the GUI
/*0
connect(mZincWidget, SIGNAL(contextAboutToBeDestroyed()),
this, SLOT(createAndSetZincContext()));
connect(mZincWidget, SIGNAL(graphicsInitialized()),
this, SLOT(graphicsInitialized()));
connect(mZincWidget, SIGNAL(devicePixelRatioChanged(const int &)),
this, SLOT(devicePixelRatioChanged(const int &)));
*/

mGui->setupUi(this);
addWidget(mZincWidget);

// Create and set our Zinc context
//TODO
//createAndSetZincContext();

}

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

MappingViewWidget::~MappingViewWidget()
{
// Delete the GUI

delete mGui;
delete mZincContext;
}

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

void MappingViewWidget::retranslateUi()
{
// Retranslate our GUI

mGui->retranslateUi(this);

// Update ourself too since some widgets will have been reset following the
// retranslation (e.g. mGui->fileNameValue)

Expand All @@ -84,17 +110,6 @@ void MappingViewWidget::retranslateUi()

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

QWidget * MappingViewWidget::widget(const QString &pFileName)
{
Q_UNUSED(pFileName)

// Return the requested (self) widget

return this;
}

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

void MappingViewWidget::initialize(const QString &pFileName)
{
// Retrieve the editing widget associated with the given file, if any
Expand All @@ -109,20 +124,8 @@ void MappingViewWidget::initialize(const QString &pFileName)
mEditingWidgets.insert(pFileName, mEditingWidget);
}

//TODO to throw away
mGui->fileNameValue->setText(pFileName);

Core::FileManager *fileManagerInstance = Core::FileManager::instance();

mGui->lockedValue->setText(fileManagerInstance->isLocked(pFileName)?tr("Yes"):tr("No"));

QString sha1Value = fileManagerInstance->sha1(pFileName);

mGui->sha1Value->setText(sha1Value.isEmpty()?"???":sha1Value);
mGui->sizeValue->setText(Core::sizeAsString(quint64(QFile(pFileName).size())));

mGui->variablesList->setModel(mEditingWidget->listViewModelVariables()); //TODO set only when charging the plugin ?
mGui->outputList->setModel(mEditingWidget->listViewModelOutput());
//mListWidgetVariables->setModel(mEditingWidget->listViewModelVariables()); //TODO set only when charging the plugin ?
//mGui->outputList->setModel(mEditingWidget->listViewModelOutput());
}

//==============================================================================
Expand Down Expand Up @@ -167,14 +170,7 @@ void MappingViewWidget::filePermissionsChanged(const QString &pFileName)

void MappingViewWidget::fileSaved(const QString &pFileName)
{
// The given file has been saved, so consider it reloaded, but only if it
// has a corresponding widget that is invisible

QWidget *crtWidget = widget(pFileName);

if ((crtWidget != nullptr) && !crtWidget->isVisible()) {
fileReloaded(pFileName);
}
Q_UNUSED(pFileName);
}

//==============================================================================
Expand Down Expand Up @@ -203,61 +199,42 @@ void MappingViewWidget::fileRenamed(const QString &pOldFileName, const QString &
}
}

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


bool MappingViewWidget::saveFile(const QString &pOldFileName, const QString &pNewFileName)
{
// Save (update) the CellML file to the given file

MappingViewEditingWidget *editingWidget = mEditingWidgets.value(pOldFileName);

return (editingWidget != nullptr)?editingWidget->cellmlFile()->update(pNewFileName):false;
}

//==============================================================================
/*
void MappingViewWidget::update(const QString &pFileName)
void MappingViewWidget::createAndSetZincContext()
{
// Keep track of the given file name
mFileName = pFileName;
// Initialise our GUI with some information about the given file
// Keep track of our current scene viewer's description
mGui->fileNameValue->setText(pFileName);
mZincSceneViewerDescription = mZincWidget->sceneViewer().writeDescription();
Core::FileManager *fileManagerInstance = Core::FileManager::instance();
// Create and set our Zinc context
mGui->lockedValue->setText(fileManagerInstance->isLocked(pFileName)?tr("Yes"):tr("No"));
mZincContext = new OpenCMISS::Zinc::Context("TestZinc");
QString sha1Value = fileManagerInstance->sha1(pFileName);
mZincContext->getMaterialmodule().defineStandardMaterials();
mZincContext->getGlyphmodule().defineStandardGlyphs();
mGui->sha1Value->setText(sha1Value.isEmpty()?"???":sha1Value);
mGui->sizeValue->setText(Core::sizeAsString(quint64(QFile(pFileName).size())));
mZincWidget->setContext(mZincContext);
} */

//==============================================================================
/*
void MappingViewWidget::devicePixelRatioChanged(const int &pDevicePixelRatio)
{
//TODO to confirm
// Update our scene using the given devide pixel ratio
mGui->variablesList->setModel(mListViewModelVariables); //TODO set only when charging the plugin ?
mGui->outputList->setModel(mListViewModelOutput);
//TODO
//mGui->tableView->setModel()
//Retrieve The output variables
updateOutput();
mListViewModelOutput->setStringList(*mListOutput);
// Retrieve the requested CellML file
mCellmlFile = CellMLSupport::CellmlFileManager::instance()->cellmlFile(pFileName);
OpenCMISS::Zinc::Scene scene = mZincContext->getDefaultRegion().getScene();
populateCellmlModel();
scene.beginChange();
scene.createGraphicsPoints().getGraphicspointattributes().getFont().setPointSize(pDevicePixelRatio*mAxesFontPointSize);
scene.endChange();
}
*/

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



} // namespace MappingView
} // namespace OpenCOR

Expand Down
37 changes: 33 additions & 4 deletions src/plugins/editing/MappingView/src/mappingviewwidget.h
Expand Up @@ -34,6 +34,14 @@ along with this program. If not, see <https://gnu.org/licenses>.
#include <QStringListModel> //TODO remove when over
#include <QTableView>
#include <QMap>
#include <QListWidget>

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

#include "zincbegin.h"
#include "opencmiss/zinc/fieldfiniteelement.hpp"
#include "opencmiss/zinc/timekeeper.hpp"
#include "zincend.h"

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

Expand All @@ -44,11 +52,20 @@ namespace Ui {
//==============================================================================

namespace OpenCOR {

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

namespace ZincWidget {
class ZincWidget;
} // namespace ZincWidget

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

namespace MappingView {

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

class MappingViewWidget : public Core::ViewWidget
class MappingViewWidget : public Core::SplitterWidget
{
Q_OBJECT

Expand All @@ -58,8 +75,6 @@ class MappingViewWidget : public Core::ViewWidget

void retranslateUi() override;

QWidget * widget(const QString &pFileName) override;

void initialize(const QString &pFileName);
void finalize(const QString &pFileName);

Expand All @@ -70,11 +85,25 @@ class MappingViewWidget : public Core::ViewWidget

bool saveFile(const QString &pOldFileName, const QString &pNewFileName);

int mAxesFontPointSize;

private:
Ui::MappingViewWidget *mGui;
ZincWidget::ZincWidget *mZincWidget;
OpenCMISS::Zinc::Context *mZincContext;

QListWidget *mListWidgetVariables;
QListWidget *mListWidgetOutput;

MappingViewEditingWidget* mEditingWidget = nullptr;
QMap<QString, MappingViewEditingWidget*> mEditingWidgets;

//char *mZincSceneViewerDescription;
/*
private slots:
//void createAndSetZincContext();
void graphicsInitialized();
void devicePixelRatioChanged(const int &pDevicePixelRatio);
*/
};

//==============================================================================
Expand Down

0 comments on commit f7bdbe4

Please sign in to comment.