00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00095 #include "../include/IPSA/ipsaclasses.h"
00096 #include "../include/IPSA/IpsaSimulator.h"
00097 #include "../include/IPSA/viewer/IpsaViewerWidget.h"
00098 #include "../include/IPSA/viewer/IpsaDialog.h"
00099
00100 #include <iostream>
00101
00102 #include <Inventor/SoDB.h>
00103 #include <Inventor/SoInput.h>
00104 #include <Inventor/SoFullPath.h>
00105 #include <Inventor/nodes/SoFile.h>
00106 #include <Inventor/nodes/SoGroup.h>
00107 #include <Inventor/nodes/SoNode.h>
00108 #include <Inventor/actions/SoSearchAction.h>
00109 #include <Inventor/actions/SoWriteAction.h>
00110 #include <Inventor/lists/SbPList.h>
00111 #include <Inventor/lists/SoPathList.h>
00112
00113 #include <Inventor/Qt/SoQt.h>
00114 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
00115
00116 #include <QtCore/QObject>
00117 #include <QtGui/QPushButton>
00118
00119
00128 IpsaViewerWidget::IpsaViewerWidget(QWidget* parent, SbBool embed) :
00129 QWidget(parent),
00130 saveFile(""),
00131 ipsaSimulator(new IpsaSimulator)
00132 {
00133 setupUi(this);
00134 examinerViewer = new SoQtExaminerViewer(examinerViewerWidget, "IPSA Viewer", embed, SO_FULL_VIEWER::BUILD_ALL, SO_FULL_VIEWER::BROWSER);
00135 examinerViewer->setFeedbackVisibility(true);
00136 examinerViewer->setFeedbackSize(35);
00137 examinerViewer->setSceneGraph(new SoSeparator);
00138 examinerViewer->setBackgroundColor(SbColor(1.0f, 1.0f, 1.0f));
00139
00140
00141 examinerViewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
00142 examinerViewer->viewAll();
00143 examinerViewer->show();
00144
00145 dialog = new IpsaDialog(ipsaSimulator, this);
00146 }
00147
00148
00153 IpsaViewerWidget::~IpsaViewerWidget()
00154 {
00155 delete ipsaSimulator;
00156 }
00157
00158
00162 void IpsaViewerWidget::showDialog()
00163 {
00164 dialog->reloadData();
00165 if (dialog->isShown())
00166 dialog->raise();
00167 else
00168 dialog->show();
00169 }
00170
00171
00176 void IpsaViewerWidget::reload()
00177 {
00178 ipsaSimulator->reload();
00179 examinerViewer->setSceneGraph(ipsaSimulator->getSceneGraph());
00180 examinerViewer->viewAll();
00181 }
00182
00186 void IpsaViewerWidget::reset()
00187 {
00188 ipsaSimulator->reset();
00189 }
00190
00191
00196 void IpsaViewerWidget::save()
00197 {
00198 if (saveFile.empty())
00199 return;
00200
00201 ipsaSimulator->save(saveFile);
00202 }
00203
00204
00209 void IpsaViewerWidget::schedule()
00210 {
00211 ipsaSimulator->schedule();
00212 if (ipsaSimulator->isScheduled())
00213 scheduleButton->setText("Unschedule");
00214 else
00215 scheduleButton->setText("Schedule");
00216 }
00217
00218
00222 bool IpsaViewerWidget::isScheduled()
00223 {
00224 return ipsaSimulator->isScheduled();
00225 }
00226
00227
00233 void IpsaViewerWidget::setVerbosity(bool verbosityOn)
00234 {
00235 ipsaSimulator->setVerbosity(verbosityOn);
00236 }
00237
00238
00242 bool IpsaViewerWidget::getVerbosity()
00243 {
00244 return ipsaSimulator->getVerbosity();
00245 }
00246
00247
00252 void IpsaViewerWidget::setSceneryFilename(const std::string& newFile)
00253 {
00254 ipsaSimulator->setSceneryFilename(newFile);
00255 }