Skip to content

Commit

Permalink
Merge 057f382 into dded71b
Browse files Browse the repository at this point in the history
  • Loading branch information
LafCorentin committed Sep 22, 2020
2 parents dded71b + 057f382 commit a947f34
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 44 deletions.
Expand Up @@ -117,15 +117,13 @@ CellMLZincMappingViewEditingWidget::CellMLZincMappingViewEditingWidget(const QSt
mSaveMapping = Core::newAction(QIcon(":/oxygen/actions/document-save.png"),
mToolBarWidget);

mOpenMeshFile = Core::newAction(QIcon(":/oxygen/actions/document-open.png"),
mOpenFile = Core::newAction(QIcon(":/oxygen/actions/document-open.png"),
mToolBarWidget);

//TODO trash could be hidden when nothing selected
mClearNode = Core::newAction(QIcon(":/oxygen/actions/edit-clear.png"),
mToolBarWidget);

mOpenMappingFile = Core::newAction(QIcon(":/oxygen/actions/document-import.png"),
mToolBarWidget);
mNodeSizeWidget = new QwtWheel(mToolBarWidget);
mNodeSizeWidget->setBorderWidth(0);
mNodeSizeWidget->setFixedSize(int(0.07*availableGeometry.width()),
Expand All @@ -136,11 +134,10 @@ CellMLZincMappingViewEditingWidget::CellMLZincMappingViewEditingWidget(const QSt
mNodeSizeWidget->setValue(CellMLZincMappingViewZincWidget::nodeSizeOrigin);

mToolBarWidget->addAction(mSaveMapping);
mToolBarWidget->addAction(mOpenMeshFile);
mToolBarWidget->addAction(mOpenFile);
mToolBarWidget->addAction(mClearNode);

mToolBarWidget->addWidget(mNodeSizeWidget);
mToolBarWidget->addAction(mOpenMappingFile);

mTopSeparator = Core::newLineWidget(this);

Expand Down Expand Up @@ -203,10 +200,8 @@ CellMLZincMappingViewEditingWidget::CellMLZincMappingViewEditingWidget(const QSt

connect(mSaveMapping, &QAction::triggered,
this, &CellMLZincMappingViewEditingWidget::saveMappingSlot);
connect(mOpenMeshFile, &QAction::triggered,
this, &CellMLZincMappingViewEditingWidget::openMeshFile);
connect(mOpenMappingFile, &QAction::triggered,
this, &CellMLZincMappingViewEditingWidget::openMappingFile);
connect(mOpenFile, &QAction::triggered,
this, &CellMLZincMappingViewEditingWidget::openFile);

//create and add informative labels

Expand Down Expand Up @@ -240,6 +235,16 @@ CellMLZincMappingViewEditingWidget::CellMLZincMappingViewEditingWidget(const QSt
// Allow for things to be dropped on us

setAcceptDrops(true);

QString potentialMappingFile = pFileName;
potentialMappingFile.replace(".cellml",".json");

QFile file;
file.setFileName(potentialMappingFile);

if (file.exists()) {
openMapping(potentialMappingFile);
}
}

//==============================================================================
Expand Down Expand Up @@ -669,18 +674,20 @@ void CellMLZincMappingViewEditingWidget::saveMappingSlot()

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

void CellMLZincMappingViewEditingWidget::openMappingFile()
void CellMLZincMappingViewEditingWidget::openFile()
{
openMapping(Core::getOpenFileName("Open mapping file"));
}
QStringList files = Core::getOpenFileNames("Open mesh or mapping file");

//==============================================================================
if (files.length() == 1 && files.first().endsWith(".json")) {
openMapping(files.first());
} else {
setMeshFiles(files);
}

void CellMLZincMappingViewEditingWidget::openMeshFile()
{
setMeshFiles(Core::getOpenFileNames("Open mesh file"));
}

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

} // namespace MappingView
} // namespace OpenCOR

Expand Down
Expand Up @@ -133,8 +133,7 @@ class CellMLZincMappingViewEditingWidget : public Core::Widget

QAction *mClearNode;
QAction *mSaveMapping;
QAction *mOpenMeshFile;
QAction *mOpenMappingFile;
QAction *mOpenFile;

QFrame *mTopSeparator;
QFrame *mBottomSeparator;
Expand Down Expand Up @@ -175,8 +174,7 @@ private slots:
void emitHorizontalSplitterMoved();
void emitVerticalSplitterMoved();
void saveMappingSlot();
void openMeshFile();
void openMappingFile();
void openFile();
};

//==============================================================================
Expand Down
Expand Up @@ -77,8 +77,6 @@ CellMLZincMappingViewZincWidget::CellMLZincMappingViewZincWidget(QWidget *pParen

setup();

initAuxFile();

setupRegion();

draw();
Expand All @@ -95,7 +93,6 @@ CellMLZincMappingViewZincWidget::~CellMLZincMappingViewZincWidget()
void CellMLZincMappingViewZincWidget::changeSource(const QStringList &pZincMeshFileNames)
{
mZincMeshFileNames = pZincMeshFileNames;
initAuxFile();

//TODO the emit launched by reset make opencor crashing
//reset();
Expand Down Expand Up @@ -274,26 +271,6 @@ void CellMLZincMappingViewZincWidget::setupRegion()

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

void CellMLZincMappingViewZincWidget::initAuxFile()
{
// For each exnode file, seek for the exelem

for (auto file : mZincMeshFileNames) {
if (file.endsWith(".exnode")) {
QString newFile = file;
newFile.remove(".exnode");
newFile.append(".exelem");
QFileInfo check_file;
check_file.setFile(newFile);
if (check_file.exists() && !mZincMeshFileNames.contains(newFile)) {
mZincMeshFileNames.append(newFile);
}
}
}
}

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

void CellMLZincMappingViewZincWidget::draw()
{

Expand Down
Expand Up @@ -117,7 +117,6 @@ public slots:
OpenCMISS::Zinc::GraphicsPoints mNodePoints;
OpenCMISS::Zinc::GraphicsPoints mMappedPoints;

void initAuxFile();
void setup();
void setupRegion();
void draw();
Expand Down

0 comments on commit a947f34

Please sign in to comment.