/*
** 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 interface_graphic.cpp
*\brief This is graphical interface C source code.
*/
#include
#include
#include
#include
"
"The main page project is: http://vite.gforge.inria.fr/.
"));
}
void Interface_graphic::on_show_stats_triggered(){
if(_core->get_trace() != NULL) {
if(_stats_window == NULL) { //Creation of the window
_stats_window = new Stats_window(this);
}
_stats_window->set_filename(_core->get_filename());
_stats_window->set_trace(_core->get_trace());
_stats_window->init_window();
_stats_window->show();
}
else {
error("Must load a trace before viewing stats");
}
}
void Interface_graphic::on_actionCommand_triggered(){
//TODO
if(_core->get_trace()){
// _cmd_window = new Command_window(_core->get_trace(),this);
_cmd_window->set_trace(_core->get_trace());
_cmd_window->init_window();
_cmd_window->show();
}
else{
error("Must load a trace before using an external command on a trace");
}
}
void Interface_graphic::on_no_warning_triggered(){
_no_warning = !_no_warning;
}
void Interface_graphic::on_no_arrows_triggered(){
Info::Render::_no_arrows = !Info::Render::_no_arrows;
_core->launch_action(Core::_STATE_RENDER_UPDATE);
}
void Interface_graphic::on_no_events_triggered(){
Info::Render::_no_events = !Info::Render::_no_events;
_core->launch_action(Core::_STATE_RENDER_UPDATE);
}
void Interface_graphic::on_zoom_in_triggered(){
Element_pos t = 1;
if (true==Info::Render::_key_alt)/* on Y axe */
_core->launch_action(Core::_STATE_RENDER_AREA_CHANGE_SCALE_Y, &t);
else/* on X axe */
_core->launch_action(Core::_STATE_RENDER_AREA_CHANGE_SCALE, &t);
}
void Interface_graphic::on_zoom_out_triggered(){
Element_pos t = -1;
if (true==Info::Render::_key_alt)/* on Y axe */
_core->launch_action(Core::_STATE_RENDER_AREA_CHANGE_SCALE_Y, &t);
else/* on X axe */
_core->launch_action(Core::_STATE_RENDER_AREA_CHANGE_SCALE, &t);
}
void Interface_graphic::on_goto_start_triggered(){
int id;
if (true==Info::Render::_key_alt)/* on Y axe */
id = Info::Render::Y_TRACE_BEGINNING;
else/* on X axe */
id = Info::Render::X_TRACE_BEGINNING;
_core->launch_action(Core::_STATE_RENDER_AREA_REGISTERED_TRANSLATE, &id);
}
void Interface_graphic::on_goto_end_triggered(){
int id;
if (true==Info::Render::_key_alt)/* on Y axe */
id = Info::Render::Y_TRACE_ENDING;
else/* on X axe */
id = Info::Render::X_TRACE_ENDING;
_core->launch_action(Core::_STATE_RENDER_AREA_REGISTERED_TRANSLATE, &id);
}
void Interface_graphic::on_show_all_trace_triggered(){
int id = Info::Render::X_TRACE_ENTIRE;/* on X axe */
_core->launch_action(Core::_STATE_RENDER_AREA_REGISTERED_TRANSLATE, &id);
id = Info::Render::Y_TRACE_ENTIRE;/* on Y axe */
_core->launch_action(Core::_STATE_RENDER_AREA_REGISTERED_TRANSLATE, &id);
}
void Interface_graphic::on_zoom_box_textChanged(QString s){
QRegExp reg_exp_number("^(\\d+)");
QString result;
Element_pos d;
if (s=="")/* if there is not value, go out */
return;
if (_zoom_box_check_value == s)/* We have just change the zoom box value (in change_zoom_box_value()) what emits the signal.
So ignore this function call */
return;
if (-1 != reg_exp_number.indexIn(s)){/* match a number */
result = reg_exp_number.cap(1);/* capture number inside parenthesis in the RegExp */
d = 0.01*result.toDouble();
if (0 == d)/* if zoom is null ignore it */
return;
_core->launch_action(Core::_STATE_RENDER_AREA_REPLACE_SCALE, &d);
}
}
void Interface_graphic::on_x_scroll_valueChanged(int new_value){
if (!_on_manual_change){
Element_pos converted_new_value = real_to_virtual_scroll_unit(new_value, 'x');/* change type of new_value */
_core->launch_action(Core::_STATE_RENDER_AREA_REPLACE_TRANSLATE, &converted_new_value);
}
}
void Interface_graphic::on_y_scroll_valueChanged(int new_value){
if (!_on_manual_change){
Element_pos converted_new_value = real_to_virtual_scroll_unit(new_value, 'y');/* change type of new_value */
_core->launch_action(Core::_STATE_RENDER_AREA_REPLACE_TRANSLATE_Y, &converted_new_value);
}
}
void Interface_graphic::on_scale_container_state_valueChanged(int new_value){
_core->launch_action(Core::_STATE_RENDER_AREA_CHANGE_CONTAINER_SCALE, &new_value);
}
void Interface_graphic::closeEvent(QCloseEvent *event){
// _ui_help_widget->close();
if(isEnabled()){
event->accept();/* accept to hide the window for a further destruction */
}
else{
event->ignore();
}
}
const std::string Interface_graphic::get_filename() const{
return _trace_path;
}
Core * Interface_graphic::get_console(){
return _core;
}
void Interface_graphic::dragEnterEvent(QDragEnterEvent *event) {
setBackgroundRole(QPalette::Highlight);
event->acceptProposedAction();
}
void Interface_graphic::dragMoveEvent(QDragMoveEvent *event) {
event->acceptProposedAction();
}
void Interface_graphic::dragLeaveEvent(QDragLeaveEvent *event) {
event->accept();
}
void Interface_graphic::dropEvent(QDropEvent *event) {
const QMimeData *mimeData = event->mimeData();
if(!mimeData->hasUrls()) {
return ;
}
foreach (QUrl url, event->mimeData()->urls()) {
#ifdef WIN32
const QString filename = url.toString().right(url.toString().size()-8);
#else
// We remove file:// from the filename
const QString filename = url.toString().right(url.toString().size()-7);
#endif
open_trace(filename);
}
}
void Interface_graphic::open_trace(const QString &filename) {
if (_is_rendering_trace == true){ /* open a new process */
QStringList arguments = (QStringList() << filename);
QString program;
const QString** run_env = _core->get_runenv();
QDir::setCurrent(*run_env[0]);
QString run_cmd = *run_env[1];
#ifdef VITE_DEBUG
cout << __FILE__ << " " << __LINE__ << " : " << run_env[0]->toStdString() << " " << run_env[1]->toStdString() << endl;
#endif
if (run_cmd.startsWith("."))
program = *run_env[0]+(run_cmd.remove(0,1));
else
program = run_cmd;
QProcess new_process;
new_process.startDetached(program, arguments);
}
else{
opening_file(filename.toStdString());
if(false==_core->draw_trace(filename.toStdString(), Core::_DRAW_OPENGL))
error("Draw trace failed");
}/* end else of if (_is_rendering_trace == true) */
}