Commit 6a4961db authored by Augustin Degomme's avatar Augustin Degomme

fixes :

- fix build on windows platforms where getopt is not present : add a version of getopt called xgetopt (license ok) when called on Windows.
- fix parsing issues with Paje traces on Windows, caused by the switch to std::getline, and the fact that it now removes the endline character (the character after the end of an std::line is seen as a \n on linux, so the bug is not apparent but still present)

feature :
- add a window that allows the user to select the containers to display, reorder them or hide them (by drag and drop and checking/unchecking). The selected display can be saved to an xml file, and reloaded for another trace. Found in Preferences/Node Selection
- add the flag -c to specify such an xml file to load initially for a trace

known issues and todo :
- only works with OpenGl render : separate interface from work on the xml file to allow use with SVC
- zoom is badly handled, and containers are not redrawn with new sizes yet
- no tests done with non Paje traces, should work though
- lacks comments and cleaning
- put the window as a plugin ?
parent 887128d9
......@@ -98,8 +98,11 @@ SET(VITE_HDRS
interface/Interface.hpp
interface/Settings_window.hpp
interface/Interface_graphic.hpp
interface/Node_select.hpp
interface/viteqtreewidget.hpp
# Core header
core/Core.hpp
core/getopt.h
# Parser headers
parser/ParsingThread.hpp
parser/Parser.hpp
......@@ -132,6 +135,7 @@ SET(VITE_UIS
interface/stats_viewer.ui
interface/global_cmd.ui
interface/list_of_counter_to_export.ui
interface/node_select.ui
)
SET(VITE_SRCS
......@@ -194,12 +198,15 @@ SET(VITE_SRCS
# Interface code files
interface/Settings_window.cpp
interface/Interface_graphic.cpp
interface/Node_select.cpp
interface/viteqtreewidget.cpp
# Plugin code file
plugin/Command_window.cpp
plugin/Plugin_window.cpp
plugin/Plugin.cpp
# Core code files
core/Core.cpp
core/getopt.c
# Main
main.cpp
)
......
......@@ -55,11 +55,17 @@
#include <map>
#include <vector>
#include <stack>
#ifndef WIN32
#include <cmath>
#include <unistd.h>
#include <unistd.h>*
#if defined(HAVE_GETOPT_H)
#include <getopt.h>
#endif /* defined(HAVE_GETOPT_H) */
#else
#include <core/getopt.h>
#endif
/* -- */
#include <QObject>
//#include <QtUiTools>/* for the run-time loading .ui file */
......@@ -102,6 +108,7 @@
/* -- */
#include "statistics/Stats_window.hpp"
/* -- */
#include "interface/Node_select.hpp"
#include "interface/Interface_graphic.hpp"
#include "core/Core.hpp"
/* -- */
......@@ -320,18 +327,24 @@ bool Core::draw_trace(const string & filename, const int format) {
if (Info::Render::_x_min_visible == Info::Render::_x_max_visible){// first time
_trace->set_interval_constrained(new Interval(0,_trace->get_max_date()));
}else{
// _trace->set_interval_constrained(new Interval(Info::Render::_x_min_visible, Info::Render::_x_max_visible));
_trace->set_interval_constrained(new Interval(Info::Render::_x_min_visible, Info::Render::_x_max_visible));
//
// WARNING I HAVE COMMENTED THIS LINE BECAUSE I FOUND IT USELESS. I TRIED AFTER AND NO BUG APPEARED
// MOREOVER IT ENABLES THE PLUGIN TIME SELECTION
//
}
// if(_state & _STATE_IN_AN_INTERVAL) {
// _trace->set_interval_constrained(new Interval(_time_start,_time_end));
// }
if (_DRAW_OPENGL == format) {
if(!_xml_config_file.empty() && _trace->get_view_root_containers()->empty()){//if we have a partial loading, process it here, but only once
launch_action(_DRAW_OPENGL_PARTIAL,NULL);
}
drawing_ogl.build(&render, _trace);
_render_opengl->build();
// _render_opengl->updateGL();
......@@ -413,13 +426,14 @@ int Core::run(){
*
*
**********************************/
#define GETOPT_STRING "t:e:i:h"
#define GETOPT_STRING "t:e:c:i:h"
#if defined(HAVE_GETOPT_LONG)
static struct option long_options[] =
{
{"interval", required_argument, 0, 't'},
{"export", required_argument, 0, 'e'},
{"load_containers_config", required_argument, 0, 'c'},
{"input", required_argument, 0, 'i'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
......@@ -488,6 +502,10 @@ int Core::get_state(int argc, char** argv){
case 'h' :
return _STATE_DISPLAY_HELP;
case 'c' :
_xml_config_file = optarg;
//cerr << "Export in file: " << _path_to_export << endl;
break;
default:
continue;
......@@ -790,11 +808,30 @@ void Core::launch_action(int state, void* arg) {
case _STATE_RENDER_UPDATE:
_render_opengl->updateGL();
break;
case _STATE_CLEAN_RENDER_AREA:
if (_render_opengl->unbuild()==false)
message << "Close file : an error occured while cleaning the render." << Message::ende;
break;
case _STATE_RENDER_SHOW_MINIMAP:
_render_opengl->show_minimap();
break;
case _DRAW_OPENGL_PARTIAL:
{
_main_window->get_node_select()->set_trace(_trace);
bool xml_success = _main_window->get_node_select()->load_config_from_xml(QString(_xml_config_file.c_str()));
if(xml_success){
std::list<Container *> displayed_containers;
_main_window->get_node_select()->build_displayed_nodes(displayed_containers);
_trace->set_view_root_containers(displayed_containers);
}else{
message << "Error while parsing" << _xml_config_file << Message::ende;
}
break;
}
default:/* like _STATE_UNKNOWN */
display_help();
warning(string("Cannot determine the arguments past. Please check the correct syntax."));
......@@ -812,6 +849,7 @@ void Core::display_help(){
<< " -a display all the inputfile (Default)" << endl
<< " -t [T0]:[T1] display the interval [T0:T1] (Default: T0 = 0 and T1 = Tmax)" << endl
<< " -e outputfile export the trace file in the svg format to outpufile" << endl
<< " -c xmlfile import a list of containers to display from an xml file" << endl
<< endl;
}
......
......@@ -212,6 +212,7 @@ public:
*/
static const int _DRAW_OPENGL_PARTIAL = 24;
static const int _STATE_CLEAN_RENDER_AREA = 25;
/*!
* \brief Launch an action according to the argument state value.
* \param state An integer corresponding to a kind of action which must be executed.
......@@ -302,6 +303,11 @@ protected:
*/
std::string _file_opened;
/*!
*\brief If a container's config file has to be opened, this attribute contains its path.
*/
std::string _xml_config_file;
/*!
*\brief If a file must be exported, this attribute contains its path.
*/
......
#include <windows.h>
#include <stdio.h>
char *optarg; // global argument pointer
int optind = 0; // global argv index
char c;
char *cp;
int getopt(int argc, char *argv[], char *optstring)
{
static char *next = NULL;
if (optind == 0)
next = NULL;
optarg = NULL;
if (next == NULL || *next == '\0')
{
if (optind == 0)
optind++;
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
{
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
if (strcmp(argv[optind], "--") == 0)
{
optind++;
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
next = argv[optind];
next++; // skip past -
optind++;
}
c = *next++;
cp = strchr(optstring, c);
if (cp == NULL || c == ':')
return '?';
cp++;
if (*cp == ':')
{
if (*next != '\0')
{
optarg = next;
next = NULL;
}
else if (optind < argc)
{
optarg = argv[optind];
optind++;
}
else
{
return '?';
}
}
return c;
}
\ No newline at end of file
/******************************************************************************
fgdump - by fizzgig and the foofus.net group
Copyright (C) 2005 by fizzgig
http://www.foofus.net
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
******************************************************************************/
// XGetopt.h Version 1.2
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef XGETOPT_H
#define XGETOPT_H
extern "C" int optind, opterr;
extern "C" char *optarg;
extern "C" int getopt(int argc, char *argv[], char *optstring);
#endif //XGETOPT_H
\ No newline at end of file
......@@ -118,9 +118,21 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa
_progress_dialog = NULL;
_plugin_window = NULL;
_ui_settings = NULL;
_ui_node_selection=NULL;
// _cmd_window = NULL;
_cmd_window = new Command_window(this,this);
if (!_ui_node_selection) {
_ui_node_selection = new Node_select(this, 0);
if(_core->get_trace()){
_ui_node_selection->set_trace(_core->get_trace());
}
//connect( _ui_node_selection, SIGNAL(settings_changed()), this, SLOT(update_settings()));
// To close the window when we quit the application
connect(quit, SIGNAL(triggered()), _ui_node_selection, SLOT(close()));
}
// For drag and drop operations
setAcceptDrops(true);
}
......@@ -837,6 +849,21 @@ void Interface_graphic::on_show_settings_triggered() {
_ui_settings->show();
}
void Interface_graphic::on_node_selection_triggered() {
if (!_ui_node_selection) {
_ui_node_selection = new Node_select(this, 0);
if(_core->get_trace()){
_ui_node_selection->set_trace(_core->get_trace());
}
//connect( _ui_node_selection, SIGNAL(settings_changed()), this, SLOT(update_settings()));
// To close the window when we quit the application
connect(quit, SIGNAL(triggered()), _ui_node_selection, SLOT(close()));
}
_ui_node_selection->show();
}
void Interface_graphic::on_actionCommand_triggered(){
if(_core->get_trace()){
if (!_cmd_window)
......@@ -985,6 +1012,9 @@ Core * Interface_graphic::get_console(){
return _core;
}
Node_select* Interface_graphic::get_node_select(){
return _ui_node_selection;
}
void Interface_graphic::update_recent_files_menu() {
const QStringList filenames = Session::get_recent_files();
QString absoluteFilename;
......
......@@ -70,6 +70,7 @@ class QProgressDialog;
/* Global informations */
#include "interface/Interface.hpp"
#include "interface/Settings_window.hpp"
#include "interface/Node_select.hpp"
/*!
*\brief This class is a graphical interface which creates a window, it inherited from the Interface interface.
......@@ -217,6 +218,11 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
* \brief Dialog box to allow user to set its ViTE environment. (change color, text size, etc.)
*/
Settings_window* _ui_settings;
/*!
* \brief Dialog box to allow user to select nodes to display
*/
Node_select* _ui_node_selection;
/*!
* \brief Text area which informs the user about the trace resume.
......@@ -471,6 +477,12 @@ public:
*/
Core *get_console();
/*!
* \fn get_node_select()
* \brief To get the node selection console
*/
Node_select* get_node_select();
/*!
* \fn update_recent_files_menu()
* \brief update the recent files opened menu
......@@ -589,6 +601,11 @@ protected slots:
*\brief A slot called when 'Settings' in the menu is clicked.
*/
void on_show_settings_triggered();
/*!
*\brief A slot called when 'Node selection' in the menu is clicked.
*/
void on_node_selection_triggered();
/*!
* \brief A slot called when 'command' in the menu is clicked.
......
This diff is collapsed.
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
/*!
*\file Stats_window.hpp
*/
#ifndef NODE_SELECT_HPP
#define NODE_SELECT_HPP
class Node_select;
/* For moc compilation */
#include <string>
#include <map>
#include <list>
/* -- */
#include <QWidget>
#include "ui_node_select.h"
#include "trace/values/Values.hpp"
#include "trace/EntityValue.hpp"
#include "trace/EntityTypes.hpp"
#include "trace/Entitys.hpp"
#include "trace/tree/Interval.hpp"
#include "trace/Trace.hpp"
#include "interface/Interface_graphic.hpp"
class QDomElement;
class QDomDocument;
/* -- */
/*!
* \class Node select
* \brief Class used to select which containers should be displayed
*
*/
class Node_select : public QWidget, protected Ui::node_selector {
Q_OBJECT
private:
std::vector<Container *> _initial_containers;
std::list<Container *> _displayed_containers;
int _number_of_selected_container;
int _screen_width, _screen_height;
std::string _file_viewed;
Trace* _trace;
Interface_graphic *_console;
public:
/*!
* Default constructor
* \param parent The parent widget of the window.
*/
Node_select( Interface_graphic *console, QWidget *parent = 0);
~Node_select();
/*!
* \fn set_initial_container_names()
* \brief Set the names of the containers in the trees
*/
void set_initial_container_names();
/*!
* \fn set_initial_container_names()
* \brief Set the names of the containers in the trees
*/
void set_displayed_container_names();
/*!
* \fn set_trace(Trace *trace)
* \brief Set the trace parsed (give the container names)
* \param trace The trace.
*/
void set_trace(Trace *trace);
/*!
* \fn set_filename(std::string filename)
* \brief Set the name of the file trace.
* \param filename The file name.
*/
void set_filename(std::string filename);
/*!
* \fn init_window()
* \brief Initialise the node selection window : set the container names, expand the lists
and clear what could have been here before
*/
void init_window();
/*!
* \fn close_window()
* \brief Properly close the window
*/
void close_window();
bool load_config_from_xml(QString filename);
void build_displayed_nodes( std::list<Container *>& displayed_containers);
private:
void set_container_names_rec(QTreeWidgetItem *current_node, Container *current_container, QFlags<Qt::ItemFlag>);
/*!
* \brief Fill the vector of selected containers depending on the ones chosen in the tree widget
*/
void set_displayed_nodes(std::string);
void reassign_children_rec(QTreeWidgetItem* item, QFlags<Qt::CheckState> flg);
/*!
* \brief This functions receives all keyboard events.
* \param event The event triggered by the keyboard event.
*/
void keyPressEvent(QKeyEvent *event);
void export_children_rec(QTreeWidgetItem* item, QDomElement& parent, QDomDocument& doc);
void load_names_rec(QTreeWidgetItem *current_node, Container *current_container, QFlags<Qt::ItemFlag> flg, QDomElement& element);
private slots:
void on_reset_button_clicked();
void on_export_button_clicked();
void on_load_button_clicked();
public slots: // just for testing, remove
void on_display_button_clicked();
};
#endif // NODE_SELECT_HPP
......@@ -248,6 +248,7 @@
<addaction name="show_plugins"/>
<addaction name="separator"/>
<addaction name="show_settings"/>
<addaction name="node_selection"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
......@@ -530,6 +531,11 @@
<string>Settings</string>
</property>
</action>
<action name="node_selection">
<property name="text">
<string>Node Selection</string>
</property>
</action>
<action name="shaded_states">
<property name="checkable">
<bool>true</bool>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>node_selector</class>
<widget class="QWidget" name="node_selector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>612</height>
</rect>
</property>
<property name="windowTitle">
<string>Node Selection</string>
</property>
<widget class="QTreeWidget" name="_nodes_original">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>281</width>
<height>481</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="dragEnabled">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>1</string>
</property>
</column>
</widget>
<widget class="viteQTreeWidget" name="_nodes_displayed">
<property name="geometry">
<rect>
<x>340</x>
<y>40</y>
<width>281</width>
<height>481</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>1</string>
</property>
</column>
</widget>
<widget class="QPushButton" name="load_button">
<property name="geometry">
<rect>
<x>440</x>
<y>530</y>
<width>85</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
<widget class="QPushButton" name="export_button">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>530</x>
<y>530</y>
<width>85</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Export</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>110</x>
<y>20</y>
<width>101</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Initial nodes :</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>430</x>
<y>20</y>
<width>121</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Displayed nodes :</string>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>530</y>
<width>331</width>
<height>31</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>