Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit c6ed7438 authored by promayon's avatar promayon
Browse files

NEW Close All action (application family)

NEW Save As action (application family)
NEW Save All action (application family)
NEW Quit action (application family)
NEW ClearSelection action (application family)
NEW About... action (application family)
NEW ShowConsole action (application family)
NEW application actions are now used in MainWindow (e.g. Open Action...)
NEW better management of recent documents list (now in Application)
NEW all actions are now embedded by default
NEW All dynamic extensions (component and action extensions) are now managed by ExtensionManager -> ActionManager and Component/ExtensionManager deleted
NEW All instances of Action and Component + the selection are now managed by Application -> ComponentManager deleted
NEW PhysicalModel Component shows properties
NEW Action has now an apply status
NEW Application icon in color and better resolution
NEW Application needs a name (identifier)
NEW MainWindow can now save its complete state (state of the docks) and geometry, it also depends on the application's name (e.g. geometry of simple is a different setting as the geometry of imp)
NEW ImpMainWindow can now restore the default state for docks, toolbar, status bar and geometry
NEW Viewer.cpp (I always knew it was bound to create this file at some stage)
NEW renamed DefaultActionWidget -> ActionWidget
NEW Action has now a default getWidget (simplification for everyone)
NEW ActionViewer update the family combo box accoring to Celine's standard
NEW Contextual menu / Action menu is now sorted by family (alphabetically) and then by action (alphabetically)
FIXED Action header/API
FIXED better architecture for RigidTransfrom action
FIXED cleaner code/MVC architecture for Decimation action
FIXED Decimation dialog: details now disabled by default
FIXED Code cleaning for some #include that were not needed anymore (mainly ExtensionsManager)
FIXED Action name is now also QObject name
FIXED macro action_extension can now install action headers using HEADERS_TO_INSTALL (but should never be needed)
FIXED generation of Doxyfile from doxyconf.in
FIXED MainWindow code cleaning (due to the extensive use of application actions)
FIXED clean vtkMeshComponentPopup -> towards pure actions
FIXED MML popup does not need close anymore (using the Application Action now)
FIXED ImpMainWindow Save action now available when the component has been modified
FIXED ImpMainWindow subtitle update using the currently selected filename + add a "*" at the end of the name is the top level component is modified
FIXED InteractiveViewer settings now are dependent of the application's name (fancy does not change the background in imp!)
FIXED Closing the main window (or derived) is the same as quitting the application (prompt user if needed to save modified data, save state and quit)
FIXED MainWindow now should preferably accessed through Application
FIXED Application/MainWindow headers include cleaning
FIXED removing all "slot" prefix for slot method names
FIXED ImageComponent and MeshComponent instanciated directly using vtkImageData and vtkPointSet are now initially marked as modified (i.e., unsaved)



git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@128 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 0e17d2ce
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "AboutAction.h"
#include <Application.h>
#include <Core.h>
using namespace camitk;
#include <QMessageBox>
#include <QBoxLayout>
#include <QLabel>
#include <QDialogButtonBox>
// --------------- constructor -------------------
AboutAction::AboutAction(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("About...");
setEmbedded(false);
setDescription("Show a little dialog about the application");
setComponent("");
setIcon(QPixmap(":/camiTKIcon"));
// Setting classification family and tags
setFamily("Application");
addTag("About");
}
// --------------- destructor -------------------
AboutAction::~AboutAction() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
// --------------- getWidget --------------
QWidget * AboutAction::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus AboutAction::apply() {
QDialog *aboutDialog = new QDialog();
aboutDialog->setWindowTitle("About " + Application::getName() + "...");
QVBoxLayout *dialogLayout = new QVBoxLayout;
QHBoxLayout *informationLayout = new QHBoxLayout;
QLabel *logo = new QLabel;
logo->setPixmap(QPixmap(":/camiTKIcon"));
QLabel *text = new QLabel;
text->setTextFormat(Qt::RichText);
text->setOpenExternalLinks(true);
text->setText("<b>"+Application::getName() + "</b><br/>"
+"Build using "
+ QString(Core::version) + "<br/>"
+ "Please visit <a href='http://camitk.imag.fr'>camitk.imag.fr</a> for more information.<br/>"
+ "(c) UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525");
// get the proper text height
text->adjustSize();
// fix the logo's height
logo->setFixedSize(text->height(), text->height());
logo->setScaledContents(true);
informationLayout->addWidget(logo);
informationLayout->addWidget(text);
dialogLayout->addLayout(informationLayout);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, SIGNAL(accepted()), aboutDialog, SLOT(accept()));
dialogLayout->addWidget(buttonBox);
aboutDialog->setLayout(dialogLayout);
aboutDialog->setWindowIcon(QPixmap(":/camiTKIcon"));
aboutDialog->exec();
return SUCCESS;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef ABOUTACTION_H
#define ABOUTACTION_H
#include <Action.h>
using namespace camitk;
class AboutAction : public Action {
public:
/// Default Constructor
AboutAction(ActionExtension * extension);
/// Default Destructor
virtual ~AboutAction();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* it shows a little about dialog.
*/
virtual ApplyStatus apply();
};
#endif // ABOUTACTION_H
......@@ -28,8 +28,15 @@ $CAMITK_LICENCE_END$
#include <Action.h>
#include "OpenAction.h"
#include "SelectLastInstanciatedAction.h"
#include "ClearSelectionAction.h"
#include "SaveAction.h"
#include "CloseAction.h"
#include "CloseAllAction.h"
#include "SaveAsAction.h"
#include "SaveAllAction.h"
#include "QuitAction.h"
#include "ShowConsoleAction.h"
#include "AboutAction.h"
// --------------- declare the extension -------------------
Q_EXPORT_PLUGIN2(applicationaction, ApplicationActionExtension);
......@@ -44,6 +51,13 @@ ApplicationActionExtension::ApplicationActionExtension() : ActionExtension() {
void ApplicationActionExtension::init() {
registerNewAction(OpenAction);
registerNewAction(SelectLastInstanciatedAction);
registerNewAction(ClearSelectionAction);
registerNewAction(SaveAction);
registerNewAction(SaveAsAction);
registerNewAction(SaveAllAction);
registerNewAction(CloseAction);
registerNewAction(CloseAllAction);
registerNewAction(QuitAction);
registerNewAction(ShowConsoleAction);
registerNewAction(AboutAction);
}
\ No newline at end of file
action_extension(DEFAULT
DEFINES COMPILE_APPLICATION_ACTION_API)
\ No newline at end of file
DEFINES COMPILE_APPLICATION_ACTION_API
)
\ No newline at end of file
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "ClearSelectionAction.h"
// CamiTK
#include <Application.h>
#include <Component.h>
using namespace camitk;
// --------------- constructor -------------------
ClearSelectionAction::ClearSelectionAction(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Clear Selection");
setEmbedded(false);
setDescription("Clear the list of selected item");
setComponent("");
// Setting classification family and tags
setFamily("Application");
addTag("Clear Selection");
getQAction()->setShortcut(Qt::Key_Escape);
}
// --------------- destructor -------------------
ClearSelectionAction::~ClearSelectionAction() {
}
// --------------- getWidget --------------
QWidget * ClearSelectionAction::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus ClearSelectionAction::apply() {
Application::clearSelectedComponents();
Application::refresh();
return SUCCESS;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef CLEARSELECTION_ACTION_H
#define CLEARSELECTION_ACTION_H
#include <Action.h>
using namespace camitk;
class ClearSelectionAction : public Action {
public:
/// Default Constructor
ClearSelectionAction(ActionExtension * extension);
/// Default Destructor
virtual ~ClearSelectionAction();
/// Returns NULL: no widget at all for this action
virtual QWidget * getWidget();
public slots:
/// apply the action select the last instanciated component
virtual ApplyStatus apply();
};
#endif // CLEARSELECTION_ACTION_H
......@@ -30,16 +30,19 @@ using namespace camitk;
// --------------- constructor -------------------
CloseAction::CloseAction(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
// Setting name, description and input component
setName("Close");
setDescription("Close all the top-level of the selected components");
setEmbedded(false);
setDescription("Close the currently selected components");
setComponent("Component");
setIcon(QPixmap(":/fileClose"));
// Setting classification family and tags
this->setFamily("Application");
this->addTag("Close");
// Setting classification family and tags
setFamily("Application");
addTag("Close");
// add shortcut
getQAction()->setShortcut(QKeySequence::Close);
}
// --------------- destructor -------------------
......@@ -53,13 +56,18 @@ QWidget * CloseAction::getWidget() {
}
// --------------- apply -------------------
void CloseAction::apply() {
Action::ApplyStatus CloseAction::apply() {
QSet<Component*> allTopLevel;
// fill the toplevel component set
foreach (Component *comp, targetComponents) {
foreach (Component *comp, getTargets()) {
allTopLevel.insert(comp->getTopLevelComponent());
}
foreach (Component *topLevel, allTopLevel) {
Application::getMainWindow()->close(topLevel);
}
// close all
QSet<Component *>::const_iterator it = allTopLevel.constBegin();
while (it != allTopLevel.constEnd() && Application::close(*it))
it++;
return (it == allTopLevel.constEnd()) ? SUCCESS : ABORTED;
}
......@@ -33,19 +33,20 @@ using namespace camitk;
class CloseAction : public Action {
public:
/// Default Constructor
CloseAction(ActionExtension * extension);
public:
/// Default Constructor
CloseAction(ActionExtension * extension);
/// Default Destructor
virtual ~CloseAction();
/// Default Destructor
virtual ~CloseAction();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual void apply();
};
public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual ApplyStatus apply();
};
#endif // CLOSEACTION_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "CloseAllAction.h"
#include <Application.h>
using namespace camitk;
// --------------- constructor -------------------
CloseAllAction::CloseAllAction(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Close All");
setEmbedded(false);
setDescription("Close all components, prompting for additional information if needed");
setComponent("");
setIcon(QPixmap(":/fileClose"));
// Setting classification family and tags
setFamily("Application");
addTag("Close");
}
// --------------- destructor -------------------
CloseAllAction::~CloseAllAction() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
// --------------- getWidget --------------
QWidget * CloseAllAction::getWidget() {
return NULL;
}
// --------------- apply -------------------
Action::ApplyStatus CloseAllAction::apply() {
Application::showStatusBarMessage( tr ( "Closing all the documents..." ) );
// clear the selection
Application::clearSelectedComponents();
// close 'em all
bool continueClosing = true;
while (continueClosing && Application::getTopLevelComponents().size() > 0) {
Component * comp = Application::getTopLevelComponents().first();
continueClosing = Application::close(comp);
}
if (continueClosing)
return SUCCESS;
else
return ABORTED;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#ifndef CLOSEALLACTION_H
#define CLOSEALLACTION_H
#include <QObject>
#include <Action.h>
#include <Component.h>
using namespace camitk;
class CloseAllAction : public Action {
public:
/// Default Constructor
CloseAllAction(ActionExtension * extension);
/// Default Destructor
virtual ~CloseAllAction();
/// Returns NULL: no permanent widget for this action. The GUI is run shown a one-shot dialog in apply
virtual QWidget * getWidget();
public slots:
/** this method is automatically called when the action is triggered.
* It gets all the targets' top level component and close them.
*/
virtual ApplyStatus apply();
};
#endif // CLOSEALLACTION_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* Visit http://camitk.imag.fr for more information
* Copyright (C) 2012 Celine Fouard, Emmanuel Promayon, Yannick Keraval
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*
* $CAMITK_LICENCE_END$
*****************************************************************************/
#include "OpenAction.h"
// CamiTK
#include <Application.h>
#include <ExtensionManager.h>
// Qt
#include <QFileDialog>
#include <fcntl.h>
using namespace camitk;
// --------------- constructor -------------------
OpenAction::OpenAction(ActionExtension * extension) : Action(extension) {
// Setting name, description and input component
setName("Open");
setDescription("Open a component from a file");
setComponent("");
setIcon(QPixmap(":/fileOpen"));
OpenAction::OpenAction (ActionExtension * extension) : Action (extension) {
// Setting name, description and input component
setName ("Open");
setEmbedded (false);
setDescription ("Open data (component) from a file");
setComponent ("");
setIcon (QPixmap (":/fileOpen"));
// Setting classification family and tags
setFamily ("Application");
addTag ("Open");
// Setting classification family and tags
this->setFamily("Application");
this->addTag("Open");
// add a shortcut
getQAction()->setShortcut ( QKeySequence::Open );
}
// --------------- destructor -------------------
......@@ -52,7 +61,45 @@ QWidget * OpenAction::getWidget() {
}
// --------------- apply -------------------
void OpenAction::apply() {
Application::getMainWindow()->slotFileOpen();
Action::ApplyStatus OpenAction::apply() {
Application::showStatusBarMessage(tr("Opening file..."));
// filter: extension of known file format
QString filter;
QString allKnownFiles; //example: (*.xml *.vtk *.wrl)
// first item = all known files
filter += QString ("All known files (*.") + ExtensionManager::getFileExtensions().join(" *.") + ");;";
// add the extension of loaded and valid plugins
foreach(ComponentExtension * ext, ExtensionManager::getComponentExtensions().values().toSet()) {
filter += ext->getName() + " (*." + ext->getFileExtensions().join(" *.") + ");;";
}
cout << filter.toStdString() << endl;
// Open more than one file
QStringList files = QFileDialog::getOpenFileNames (NULL, "Select One or More Files to Open", Application::getLastUsedDirectory().absolutePath(), filter);
if (!files.isEmpty()) {
bool openOk = true;