Skip to content

Commit

Permalink
ENH: Split UI into ShapePopulationQT and ShapePopulationMainWindowQT
Browse files Browse the repository at this point in the history
See #127
  • Loading branch information
jcfr committed Nov 12, 2018
1 parent e7c97d7 commit 1253892
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 134 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(CXX_FILES
gradientWidgetQT.cxx
ShapePopulationBase.cxx
ShapePopulationData.cxx
ShapePopulationMainWindowQT.cxx
ShapePopulationQT.cxx
ShapePopulationViewer.cxx
vtkPVPostFilter.cxx
Expand All @@ -31,6 +32,7 @@ set(UI_FILES
cameraDialogQT.ui
CSVloaderQT.ui
customizeColorMapByDirectionDialogQT.ui
ShapePopulationMainWindowQT.ui
ShapePopulationQT.ui
)

Expand All @@ -40,6 +42,7 @@ set(QT_WRAP
CSVloaderQT.h
customizeColorMapByDirectionDialogQT.h
gradientWidgetQT.h
ShapePopulationMainWindowQT.h
ShapePopulationQT.h
)

Expand Down
47 changes: 47 additions & 0 deletions src/ShapePopulationMainWindowQT.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

#include "ShapePopulationMainWindowQT.h"
#include "ShapePopulationQT.h"

ShapePopulationMainWindowQT::ShapePopulationMainWindowQT()
{
this->setupUi(this);

this->menuFile->addAction(this->shapePopulation()->actionOpen_Directory);
this->menuFile->addAction(this->shapePopulation()->actionOpen_VTK_Files);
this->menuFile->addAction(this->shapePopulation()->actionLoad_CSV);
this->menuFile->addSeparator();
this->menuFile->addMenu(this->menuExport);
this->menuFile->addSeparator();
this->menuFile->addAction(this->shapePopulation()->actionDelete);
this->menuFile->addAction(this->shapePopulation()->actionDelete_All);
this->menuFile->addSeparator();
this->menuFile->addAction(this->actionExit);

this->menuExport->addAction(this->shapePopulation()->actionTo_PDF);
this->menuExport->addAction(this->shapePopulation()->actionTo_PS);
this->menuExport->addAction(this->shapePopulation()->actionTo_EPS);
this->menuExport->addAction(this->shapePopulation()->actionTo_TEX);
this->menuExport->addAction(this->shapePopulation()->actionTo_SVG);

this->menuOptions->addAction(this->shapePopulation()->actionCameraConfig);
this->menuOptions->addAction(this->shapePopulation()->actionBackgroundConfig);
this->menuOptions->addSeparator();
this->menuOptions->addAction(this->shapePopulation()->actionLoad_Colorbar);
this->menuOptions->addAction(this->shapePopulation()->actionSave_Colorbar);

// Menu signals
connect(this->actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));

#if defined(Q_OS_UNIX)
Ui_ShapePopulationMainWindowQT::menuBar->setNativeMenuBar(false);
#endif
}

ShapePopulationMainWindowQT::~ShapePopulationMainWindowQT()
{
}

ShapePopulationQT* ShapePopulationMainWindowQT::shapePopulation()
{
return qobject_cast<ShapePopulationQT*>(this->centralWidget());
}
19 changes: 19 additions & 0 deletions src/ShapePopulationMainWindowQT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef SHAPEPOPULATIONMAINWINDOWQT_H
#define SHAPEPOPULATIONMAINWINDOWQT_H

#include "ui_ShapePopulationMainWindowQT.h"

class ShapePopulationQT;

class ShapePopulationMainWindowQT : public QMainWindow, public Ui::ShapePopulationMainWindowQT
{
Q_OBJECT

public:
ShapePopulationMainWindowQT();
~ShapePopulationMainWindowQT();

ShapePopulationQT* shapePopulation();
};

#endif
94 changes: 94 additions & 0 deletions src/ShapePopulationMainWindowQT.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShapePopulationMainWindowQT</class>
<widget class="QMainWindow" name="ShapePopulationMainWindowQT">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1250</width>
<height>836</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>ShapePopulationViewer 1.4.0</string>
</property>
<property name="windowIcon">
<iconset resource="ShapePopulationViewer.qrc">
<normaloff>:/resources/logo.png</normaloff>:/resources/logo.png</iconset>
</property>
<widget class="ShapePopulationQT" name="centralwidget" native="true">
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1100</width>
<height>700</height>
</rect>
</property>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1250</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<widget class="QMenu" name="menuExport">
<property name="title">
<string>Export Selection</string>
</property>
</widget>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuOptions">
<property name="title">
<string>Options</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuOptions"/>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ShapePopulationQT</class>
<extends>QWidget</extends>
<header>ShapePopulationQT.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="ShapePopulationViewer.qrc"/>
</resources>
<connections/>
</ui>
61 changes: 31 additions & 30 deletions src/ShapePopulationQT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ShapePopulationQT.h"


ShapePopulationQT::ShapePopulationQT()
ShapePopulationQT::ShapePopulationQT(QWidget* parent) : QWidget(parent)
{
this->setupUi(this);

Expand All @@ -20,23 +20,34 @@ ShapePopulationQT::ShapePopulationQT()
m_backgroundDialog = new backgroundDialogQT(this);
m_CSVloaderDialog = new CSVloaderQT(this);
m_customizeColorMapByDirectionDialog = new customizeColorMapByDirectionDialogQT(this);
m_exportActions = new QActionGroup(this);
m_exportActions->setExclusive(false);
foreach(QAction* action, QList<QAction*>()
<< actionTo_PDF << actionTo_PS << actionTo_EPS << actionTo_TEX << actionTo_SVG)
{
m_exportActions->addAction(action);
#ifdef SPV_EXTENSION
action->setText(action->text() + QString(" (Not Available)"));
#endif
}
m_optionsActions = new QActionGroup(this);
m_optionsActions->setExclusive(false);
foreach(QAction* action, QList<QAction*>()
<< actionCameraConfig << actionBackgroundConfig << actionLoad_Colorbar << actionSave_Colorbar)
{
m_optionsActions->addAction(action);
}


// GUI disable
stackedWidget_ColorMapByMagnitude->show();
stackedWidget_ColorMapByDirection->hide();
toolBox->setDisabled(true);
this->gradientWidget_VISU->disable();
menuOptions->setDisabled(true);
m_optionsActions->setDisabled(true);
actionDelete->setDisabled(true);
actionDelete_All->setDisabled(true);
menuExport->setDisabled(true);

#ifdef SPV_EXTENSION
menuExport->clear();
menuExport->addAction("PDF");
connect(menuExport->actions().at(0),SIGNAL(triggered()),this,SLOT(showNoExportWindow()));
#endif
m_exportActions->setDisabled(true);

//Pushbuttons color
pushButton_VISU_add->setStyleSheet("color: rgb(0, 200, 0)");
Expand Down Expand Up @@ -67,7 +78,6 @@ ShapePopulationQT::ShapePopulationQT()
frame_DISPLAY->setPalette( backgroundColor );

//Menu signals
connect(actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));
connect(actionOpen_Directory,SIGNAL(triggered()),this,SLOT(openDirectory()));
connect(actionOpen_VTK_Files,SIGNAL(triggered()),this,SLOT(openFiles()));
connect(actionLoad_CSV,SIGNAL(triggered()),this,SLOT(loadCSV()));
Expand All @@ -85,6 +95,8 @@ ShapePopulationQT::ShapePopulationQT()
connect(actionTo_EPS,SIGNAL(triggered()),this,SLOT(exportToEPS()));
connect(actionTo_TEX,SIGNAL(triggered()),this,SLOT(exportToTEX()));
connect(actionTo_SVG,SIGNAL(triggered()),this,SLOT(exportToSVG()));
#else
connect(m_exportActions,SIGNAL(triggered(QAction*)),this,SLOT(showNoExportWindow()));
#endif
//gradView Signals
connect(gradientWidget_VISU,SIGNAL(arrowMovedSignal(qreal)), this, SLOT(slot_gradArrow_moved(qreal)));
Expand Down Expand Up @@ -135,10 +147,6 @@ ShapePopulationQT::ShapePopulationQT()
//Display
radioButton_DISPLAY_all->toggle(); //Display All surfaces,
radioButton_SYNC_realtime->toggle();

#if __APPLE__
Ui_ShapePopulationQT::menuBar->setNativeMenuBar(false);
#endif
}


Expand All @@ -150,12 +158,6 @@ ShapePopulationQT::~ShapePopulationQT()
delete m_customizeColorMapByDirectionDialog;
}

void ShapePopulationQT::slotExit()
{
this->deleteAll();
qApp->exit();
}

void ShapePopulationQT::on_pushButton_displayTools_clicked()
{
if(m_toolsDisplayed)
Expand Down Expand Up @@ -346,8 +348,8 @@ void ShapePopulationQT::deleteAll()
gradientWidget_VISU->disable();
actionDelete_All->setDisabled(true);
actionDelete->setDisabled(true);
menuExport->setDisabled(true);
menuOptions->setDisabled(true);
m_exportActions->setDisabled(true);
m_optionsActions->setDisabled(true);

//Initialize Menu actions
actionOpen_Directory->setText("Open Directory");
Expand Down Expand Up @@ -1124,10 +1126,10 @@ void ShapePopulationQT::CreateWidgets()
/* */

this->gradientWidget_VISU->enable(&m_usedColorBar->colorPointList);
this->menuOptions->setEnabled(true);
this->m_optionsActions->setEnabled(true);
this->actionDelete->setEnabled(true);
this->actionDelete_All->setEnabled(true);
this->menuExport->setEnabled(true);
this->m_exportActions->setEnabled(true);
this->actionOpen_Directory->setText("Add Directory");
this->actionOpen_VTK_Files->setText("Add VTK/VTP files");
this->actionLoad_CSV->setText("Add CSV file");
Expand Down Expand Up @@ -1172,12 +1174,11 @@ void ShapePopulationQT::ClickEvent(vtkObject* a_selectedObject, unsigned long no
/* VTK SELECTION */
ShapePopulationBase::ClickEvent(a_selectedObject,notUseduLong,notUsedVoid);


if(m_selectedIndex.size() == 0)
{
/* DISABLE GUI ACTIONS */
this->actionDelete->setDisabled(true);
this->menuExport->setDisabled(true);
this->m_exportActions->setDisabled(true);
this->groupBox_VIEW->setDisabled(true);
this->groupBox_VISU->setDisabled(true);
this->gradientWidget_VISU->disable();
Expand All @@ -1187,7 +1188,7 @@ void ShapePopulationQT::ClickEvent(vtkObject* a_selectedObject, unsigned long no
{
/* ENABLE GUI ACTIONS */
this->actionDelete->setEnabled(true);
this->menuExport->setEnabled(true);
this->m_exportActions->setEnabled(true);
this->groupBox_VIEW->setEnabled(true);
this->groupBox_VISU->setEnabled(true);

Expand Down Expand Up @@ -1374,7 +1375,7 @@ void ShapePopulationQT::SelectAll()

/* ENABLE GUI ACTIONS */
this->actionDelete->setEnabled(true);
this->menuExport->setEnabled(true);
this->m_exportActions->setEnabled(true);
this->groupBox_VIEW->setEnabled(true);
this->groupBox_VISU->setEnabled(true);
this->gradientWidget_VISU->enable(&m_usedColorBar->colorPointList);
Expand Down Expand Up @@ -1411,7 +1412,7 @@ void ShapePopulationQT::UnselectAll()

/* DISABLE GUI ACTIONS */
this->actionDelete->setDisabled(true);
this->menuExport->setDisabled(true);
this->m_exportActions->setDisabled(true);
this->groupBox_VIEW->setDisabled(true);
this->groupBox_VISU->setDisabled(true);
this->gradientWidget_VISU->disable();
Expand Down Expand Up @@ -1511,7 +1512,7 @@ void ShapePopulationQT::on_tabWidget_currentChanged(int index)
void ShapePopulationQT::resizeEvent(QResizeEvent *Qevent)
{
//Resizing Windows
QMainWindow::resizeEvent(Qevent);
QWidget::resizeEvent(Qevent);

//According to the View Options
if (this->radioButton_DISPLAY_square->isChecked() == true )//view square meshes
Expand Down
Loading

0 comments on commit 1253892

Please sign in to comment.