GCC Code Coverage Report


Directory: ./
File: src/gui/dialog/dialogloadenvironment.cc
Date: 2024-12-20 15:53:58
Exec Total Coverage
Lines: 0 27 0.0%
Branches: 0 52 0.0%

Line Branch Exec Source
1 // Copyright (c) 2015-2018, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16
17 #include "gepetto/gui/dialog/dialogloadenvironment.hh"
18
19 #include <QDir>
20 #include <QFileDialog>
21 #include <QMessageBox>
22
23 #include "ui_dialogloadenvironment.h"
24
25 namespace gepetto {
26 namespace gui {
27 QList<DialogLoadEnvironment::EnvironmentDefinition>
28 DialogLoadEnvironment::definitions =
29 QList<DialogLoadEnvironment::EnvironmentDefinition>()
30 << DialogLoadEnvironment::EnvironmentDefinition();
31
32 DialogLoadEnvironment::DialogLoadEnvironment(QWidget *parent)
33 : QDialog(parent), ui_(new ::Ui::DialogLoadEnvironment) {
34 ui_->setupUi(this);
35 ui_->groupBox_details->setVisible(false);
36 defs_ = ui_->comboBox_defs;
37 defs_->setFocus();
38
39 foreach (EnvironmentDefinition r, definitions) {
40 defs_->addItem(r.name_, QVariant::fromValue(r));
41 }
42 }
43
44 DialogLoadEnvironment::~DialogLoadEnvironment() { delete ui_; }
45
46 void DialogLoadEnvironment::addEnvironmentDefinition(
47 QString name, QString envName, QString package, QString urdfFilename,
48 QString urdfSuffix, QString srdfSuffix) {
49 definitions.append(EnvironmentDefinition(name, envName, package, urdfFilename,
50 urdfSuffix, srdfSuffix));
51 }
52
53 QList<DialogLoadEnvironment::EnvironmentDefinition>
54 DialogLoadEnvironment::getEnvironmentDefinitions() {
55 return definitions;
56 }
57
58 void DialogLoadEnvironment::accept() {
59 /* TODO use the urdfParser::getFilename to check if the package exists
60 QDir d (ui_->packagePath->text ());
61 if (!d.cd("urdf")) {
62 QMessageBox (QMessageBox::Warning, "Directory not found", d.absolutePath(),
63 QMessageBox::Ok, this).exec(); return;
64 }
65 if (!d.exists(ui_->urdfFilename->text () + ".urdf")) {
66 QMessageBox (QMessageBox::Warning, "File not found",
67 d.absoluteFilePath(ui_->urdfFilename->text() + ".urdf"), QMessageBox::Ok,
68 this).exec(); return;
69 }
70 if (!QDir (ui_->meshDirectory->text ()).exists()) {
71 QMessageBox (QMessageBox::Warning, "File not found",
72 ui_->meshDirectory->text (), QMessageBox::Ok, this).exec(); return;
73 }*/
74 selected_ =
75 EnvironmentDefinition(defs_->currentText(), ui_->envName->text(),
76 ui_->packageName->text(), ui_->urdfFilename->text(),
77 ui_->urdfSuffix->text(), ui_->srdfSuffix->text());
78 done(QDialog::Accepted);
79 }
80
81 void DialogLoadEnvironment::envSelect(int index) {
82 QVariant v = defs_->itemData(index);
83 if (v.canConvert<EnvironmentDefinition>()) {
84 EnvironmentDefinition rd = v.value<EnvironmentDefinition>();
85 ui_->envName->setText(rd.envName_);
86 ui_->packageName->setText(rd.package_);
87 ui_->urdfFilename->setText(rd.urdfFilename_);
88 ui_->urdfSuffix->setText(rd.urdfSuf_);
89 ui_->srdfSuffix->setText(rd.srdfSuf_);
90 }
91 }
92 } // namespace gui
93 } // namespace gepetto
94