ExportDialogController.cpp
Go to the documentation of this file.
2 #include <QMessageBox>
3 
4 namespace armarx
5 {
7  {
8  exportDialog = new QDialog;
9  ui.setupUi(exportDialog);
10  fps = ui.selcetFPS->value();
11  ARMARX_INFO << "RobotTrajectoryDesigner: ExportDialogController on init";
12  }
13 
15  {
16  QObject::connect(ui.cancel, SIGNAL(clicked()), exportDialog, SLOT(reject()));
17  QObject::connect(ui.exportMMM, SIGNAL(clicked()), exportDialog, SLOT(accept()));
18 
19  QObject::connect(ui.selcetFPS, SIGNAL(valueChanged(int)), this, SLOT(setFPS(int)));
20  }
21 
23  {
24  ARMARX_INFO << "RobotTrajectoryDesigner: ExportDialogController on disconnect";
25  }
26 
28  {
29  ARMARX_INFO << "RobotTrajectoryDesigner: ExportDialogController on exit";
30  }
31 
33  {
36  }
37 
39  {
40  //fps = ui.selcetFPS->value();
41  exportDialog->setModal(true);
42  exportDialog->exec();
43  }
44 
46  {
47  this->fps = fps;
48  }
49 
50  void ExportDialogController::exportTrajectory(std::vector<armarx::DesignerTrajectoryPtr> trajectories)
51  {
52  this->trajectories = trajectories;
53  }
54 
56  {
57  if (environment == NULL)
58  {
59  return;
60  }
61  //fps = ui.selcetFPS->value();
62  //exportDialog->setModal(true);
63  //exportDialog->exec();
64  emit exportDesignerTrajectory(fps);
65  if (trajectories.empty())
66  {
67  QMessageBox* exportMMMfailed = new QMessageBox();
68  exportMMMfailed->setWindowTitle(QString::fromStdString("Error Message"));
69  exportMMMfailed->setText(QString::fromStdString("Export failed.\nNo trajectory is implemented."));
70  exportMMMfailed->exec();
71  return;
72  }
73  QString file = saveToFile();
74  //try
75  //{
76  MMMExporterPtr exporter = std::make_shared<MMMExporter>(MMMExporter(environment));
77  //exporter->exportTrajectory(trajectories, file.toStdString());
78  if (!file.isEmpty())
79  {
80  exporter->exportTrajectory(trajectories, file.toStdString());
81  }
82  else
83  {
84  ARMARX_INFO << "Export to MMM failed (file.isEmpty)";
85  }
86  }
87 
89  {
90  /*if (environment == NULL)
91  {
92  return;
93  }
94  emit exportDesignerTrajectory();
95  if (trajectories.empty())
96  {
97  QMessageBox* exportTrajectoryfailed = new QMessageBox();
98  exportTrajectoryfailed->setWindowTitle(QString::fromStdString("Error Message"));
99  exportTrajectoryfailed->setText(QString::fromStdString("Export failed.\nNo trajectory is implemented."));
100  exportTrajectoryfailed->exec();
101  return;
102  }
103  QString file = saveToFile();
104  try
105  {
106  TrajectoryExporterPtr exporter = std::make_shared<TrajectoryExporter>();
107  if (!file.isEmpty())
108  {
109  exporter->exportTrajectory(trajectories, file.toStdString());
110  }
111  else
112  {
113  ARMARX_INFO << "Export to Trajectory failed (file.isEmpty)";
114  }
115  }
116  catch (...)
117  {
118  ARMARX_INFO << "Export to Trajectory failed (Exception)";
119  }*/
120  throw armarx::NotImplementedYetException();
121  }
122 
124  {
125  this->environment = environment;
126  }
127 
128  QString ExportDialogController::saveToFile()
129  {
130  QFileDialog dialog(0);
131  dialog.setFileMode(QFileDialog::AnyFile);
132  dialog.setAcceptMode(QFileDialog::AcceptSave);
133  dialog.setDefaultSuffix(QString::fromStdString("xml"));
134  dialog.setNameFilter(tr("XML (*.xml)"));
135  QString filepath;
136 
137  if (dialog.exec())
138  {
139  if (dialog.selectedFiles().size() != 0)
140  {
141  filepath = dialog.selectedFiles()[0];
142  ARMARX_INFO << filepath.toStdString();
143  return filepath;
144  }
145  }
146  return "";
147  }
148 
149 
150 }
armarx::ExportDialogController::environmentChanged
void environmentChanged(EnvironmentPtr environment)
Set the enviroment.
Definition: ExportDialogController.cpp:123
armarx::ExportDialogController::onConnectComponent
void onConnectComponent() override
Definition: ExportDialogController.cpp:14
armarx::MMMExporter
Exports instances of the DesignerTrajectory class to .xml-files in MMM format.
Definition: MMMExporter.h:33
armarx::ExportDialogController::exportMMM
void exportMMM()
Start export to MMM.
Definition: ExportDialogController.cpp:55
armarx::ExportDialogController::setFPS
void setFPS(int fps)
Sets the timed distribution of automatically generated waypoints by assigning how many waypoints ther...
Definition: ExportDialogController.cpp:45
armarx::ExportDialogController::ExportDialogController
ExportDialogController()
Creates a new ExportDialogController and assigns a designer exporter to handle.
Definition: ExportDialogController.cpp:32
armarx::ExportDialogController::open
void open()
Opens an export dialog.
Definition: ExportDialogController.cpp:38
ExportDialogController.h
armarx::ExportDialogController::exportDesignerTrajectory
void exportDesignerTrajectory()
Requests a designer trajectory to a given index to export.
armarx::ExportDialogController::onDisconnectComponent
void onDisconnectComponent() override
Definition: ExportDialogController.cpp:22
armarx::EnvironmentPtr
std::shared_ptr< Environment > EnvironmentPtr
Definition: Environment.h:29
armarx::MMMExporterPtr
std::shared_ptr< MMMExporter > MMMExporterPtr
Definition: MMMExporter.h:47
armarx::ExportDialogController::onInitComponent
void onInitComponent() override
Definition: ExportDialogController.cpp:6
armarx::ExportDialogController::onExitComponent
void onExitComponent() override
Definition: ExportDialogController.cpp:27
armarx::ExportDialogController::exportTrajectory
void exportTrajectory()
Start export to trajectory.
Definition: ExportDialogController.cpp:88
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28