Skip to content

Commit

Permalink
got rid of .ui and installed toolbar and wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
LafCorentin committed Aug 4, 2020
1 parent b163409 commit e3a87cc
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 137 deletions.
3 changes: 1 addition & 2 deletions src/plugins/editing/MappingView/CMakeLists.txt
Expand Up @@ -15,10 +15,9 @@ add_plugin(MappingView
src/mappingviewplugin.cpp
src/mappingviewwidget.cpp
src/mappingviewzincwidget.cpp
UIS
src/mappingviewwidget.ui
PLUGINS
Core
CellMLSupport
ZincWidget
Qwt
)
11 changes: 0 additions & 11 deletions src/plugins/editing/MappingView/i18n/MappingView_fr.ts
@@ -1,17 +1,6 @@
<?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>Node:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Variable:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OpenCOR::MappingView::MappingViewPlugin</name>
<message>
Expand Down
Expand Up @@ -29,10 +29,6 @@ along with this program. If not, see <https://gnu.org/licenses>.

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

#include "ui_mappingviewwidget.h"

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

#include <QFile>
#include <QtGui>

Expand Down
95 changes: 55 additions & 40 deletions src/plugins/editing/MappingView/src/mappingviewwidget.cpp
Expand Up @@ -28,12 +28,9 @@ along with this program. If not, see <https://gnu.org/licenses>.

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

#include "ui_mappingviewwidget.h"

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

#include <QtGui>
#include <QMenu>
#include <QApplication>
#include <QScreen>

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

Expand All @@ -52,14 +49,52 @@ namespace MappingView {
//==============================================================================

MappingViewWidget::MappingViewWidget(QWidget *pParent) :
Core::SplitterWidget(pParent),
mAxesFontPointSize(0),
mGui(new Ui::MappingViewWidget)
Core::SplitterWidget(pParent)
{

// Set up the GUI
// Set our orientation

setOrientation(Qt::Vertical);

//create and add toolbar

mToolBarWidget = new Core::ToolBarWidget();

QRect availableGeometry = qApp->primaryScreen()->availableGeometry();

mDelayWidget = new QwtWheel(mToolBarWidget);

mDelayWidget->setBorderWidth(0);
mDelayWidget->setFixedSize(int(0.07*availableGeometry.width()),
mDelayWidget->height()/2);
mDelayWidget->setFocusPolicy(Qt::NoFocus);
mDelayWidget->setRange(0.0, 100.0);
mDelayWidget->setWheelBorderWidth(0);

mDelayWidget->setValue(MappingViewZincWidget::nodeSizeOrigin);

mToolBarWidget->addWidget(mDelayWidget);

addWidget(mToolBarWidget);

//create and add informative labels

QLabel *nodeLabel = new QLabel("Node:",this);
addWidget(nodeLabel);

mNodeValue = new QLabel(this);
addWidget(mNodeValue);

mGui->setupUi(this);
QLabel *variableLabel = new QLabel("Variable:",this);
addWidget(variableLabel);

mVariableValue = new QLabel(this);
addWidget(mVariableValue);

//create and add the variable tree:

mVariableTree = new QTreeView(this);
addWidget(mVariableTree);

// Keep track of our movement
/*
Expand All @@ -72,23 +107,19 @@ MappingViewWidget::MappingViewWidget(QWidget *pParent) :
//TODO
mMeshFileName = "/home/tuareg/Documents/OpenCOR/opencor/meshes/circulation.exnode";

// Create and add a Zinc widget
// add a Zinc widget

mMappingViewZincWidget = new MappingViewZincWidget(this, mMeshFileName);

//TODO move to mappingviewzincwidget and you know how it works
connect(mMappingViewZincWidget, &MappingViewZincWidget::devicePixelRatioChanged,
this, &MappingViewWidget::devicePixelRatioChanged);

connect(mMappingViewZincWidget, &MappingViewZincWidget::nodeSelection,
this, &MappingViewWidget::nodeSelection);
connect(mDelayWidget, &QwtWheel::valueChanged,
mMappingViewZincWidget, &MappingViewZincWidget::setNodeSizes );

mGui->layout->addWidget(mMappingViewZincWidget);
addWidget(mMappingViewZincWidget);

//mToolBarWidget = new Core::ToolBarWidget();



}

//==============================================================================
Expand Down Expand Up @@ -120,14 +151,14 @@ void MappingViewWidget::initialize(const QString &pFileName)
if (mEditingWidget == nullptr) {
// No editing widget exists for the given file, so create one

mEditingWidget = new MappingViewEditingWidget(pFileName, "../opencor/meshes/circulation.exnode",this);
mEditingWidget = new MappingViewEditingWidget(pFileName, mMeshFileName,this);

mEditingWidgets.insert(pFileName, mEditingWidget);
}

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

//==============================================================================
Expand Down Expand Up @@ -203,30 +234,14 @@ void MappingViewWidget::fileRenamed(const QString &pOldFileName, const QString &

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

void MappingViewWidget::devicePixelRatioChanged(const int &pDevicePixelRatio)
{
Q_UNUSED(pDevicePixelRatio);
//TODO to confirm
// Update our scene using the given devide pixel ratio
/*
OpenCMISS::Zinc::Scene scene = mZincContext->getDefaultRegion().getScene();
scene.beginChange();
scene.createGraphicsPoints().getGraphicspointattributes().getFont().setPointSize(pDevicePixelRatio*mAxesFontPointSize);
scene.endChange();
*/
}

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

void MappingViewWidget::nodeSelection(int pId) {

if (pId==-1) {
mGui->nodeValue->setText("");
mGui->variableValue->setText("");
mNodeValue->setText("");
mVariableValue->setText("");
} else {
mGui->nodeValue->setNum(pId);
mGui->variableValue->setText(mEditingWidget->getVariableOfNode(pId));
mNodeValue->setNum(pId);
mVariableValue->setText(mEditingWidget->getVariableOfNode(pId));
}
}

Expand Down
18 changes: 10 additions & 8 deletions src/plugins/editing/MappingView/src/mappingviewwidget.h
Expand Up @@ -36,12 +36,14 @@ along with this program. If not, see <https://gnu.org/licenses>.
#include <QTableView>
#include <QMap>
#include <QListWidget>
#include <QLabel>
#include <QTreeView>

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

namespace Ui {
class MappingViewWidget;
} // namespace Ui
#include "qwtbegin.h"
#include "qwt_wheel.h"
#include "qwtend.h"

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

Expand Down Expand Up @@ -85,14 +87,16 @@ class MappingViewWidget : public Core::SplitterWidget

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

int mAxesFontPointSize;

private:
Ui::MappingViewWidget *mGui;

QwtWheel *mDelayWidget;

Core::ToolBarWidget *mToolBarWidget;

MappingViewZincWidget *mMappingViewZincWidget;
QLabel *mNodeValue;
QLabel *mVariableValue;
QTreeView *mVariableTree;

QListWidget *mListWidgetVariables;
QListWidget *mListWidgetOutput;
Expand All @@ -103,10 +107,8 @@ class MappingViewWidget : public Core::SplitterWidget
QString mMeshFileName;

private slots:
void devicePixelRatioChanged(const int &pDevicePixelRatio);
void nodeSelection(int pId);


};

//==============================================================================
Expand Down
61 changes: 0 additions & 61 deletions src/plugins/editing/MappingView/src/mappingviewwidget.ui

This file was deleted.

23 changes: 14 additions & 9 deletions src/plugins/editing/MappingView/src/mappingviewzincwidget.cpp
Expand Up @@ -57,7 +57,8 @@ namespace MappingView {
MappingViewZincWidget::MappingViewZincWidget(QWidget *pParent, const QString &pMainFileName) :
ZincWidget::ZincWidget(pParent),
mMainFileName(pMainFileName),
mAuxFileName(pMainFileName)
mAuxFileName(pMainFileName),
mNodeSize(nodeSizeOrigin)
{
// Keep track of our current scene viewer's description
//TODO usefull ?
Expand Down Expand Up @@ -162,8 +163,6 @@ void MappingViewZincWidget::initializeGL()

// Size of our green spheres

mNodeSize = 20.;

OpenCMISS::Zinc::Graphicspointattributes pointAttr = nodePoints.getGraphicspointattributes();

pointAttr.setBaseSize(1, &mNodeSize);
Expand All @@ -188,7 +187,7 @@ void MappingViewZincWidget::mouseMoveEvent(QMouseEvent *pEvent)
void MappingViewZincWidget::mousePressEvent(QMouseEvent *pEvent)
{
ZincWidget::mousePressEvent(pEvent);
mouse_pos_click = pEvent->pos();
mMousePosClick = pEvent->pos();
}

//==============================================================================
Expand All @@ -197,7 +196,7 @@ void MappingViewZincWidget::mouseReleaseEvent(QMouseEvent *pEvent)
{
ZincWidget::mouseReleaseEvent(pEvent);

if (mouse_pos_click==pEvent->pos()) {
if (mMousePosClick==pEvent->pos()) {
click(pEvent);
}
}
Expand All @@ -214,10 +213,10 @@ void MappingViewZincWidget::wheelEvent(QWheelEvent *pEvent)
void MappingViewZincWidget::click(QMouseEvent *pEvent)
{
mScenePicker->setSceneviewerRectangle(mSceneViewer, OpenCMISS::Zinc::SCENECOORDINATESYSTEM_WINDOW_PIXEL_TOP_LEFT,
pEvent->x() - size_selection,
pEvent->y() - size_selection,
pEvent->x() + size_selection,
pEvent->y() + size_selection);
pEvent->x() - mSizeSelection,
pEvent->y() - mSizeSelection,
pEvent->x() + mSizeSelection,
pEvent->y() + mSizeSelection);
OpenCMISS::Zinc::Node node = mScenePicker->getNearestNode();

int id = node.getIdentifier();
Expand Down Expand Up @@ -258,6 +257,12 @@ void MappingViewZincWidget::click(QMouseEvent *pEvent)

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

void MappingViewZincWidget::setNodeSizes(int pSize) {
mNodeSize = pSize;
//TODO
initializeGL();
}

} // namespace ZincWidget
} // namespace OpenCOR

Expand Down

0 comments on commit e3a87cc

Please sign in to comment.