5 #ifndef BALL_VIEW_WIDGETS_SCENE_H
6 #define BALL_VIEW_WIDGETS_SCENE_H
8 #ifndef BALL_VIEW_KERNEL_MODULARWIDGET_H
12 #ifndef BALL_VIEW_RENDERING_GLRENDERER_H
16 #ifndef BALL_VIEW_KERNEL_COMMON_H
20 #ifndef BALL_VIEW_RENDERING_RENDERWINDOW_H
24 #ifndef BALL_VIEW_RENDERING_GLRENDERWINDOW_H
28 #ifndef BALL_VIEW_RENDERING_RENDERSETUP_H
32 #include <QtCore/QThread>
33 #include <QtCore/QTimer>
34 #include <QtGui/QDragEnterEvent>
35 #include <QtGui/QWheelEvent>
36 #include <QtGui/QKeyEvent>
37 #include <QtGui/QDropEvent>
38 #include <QtGui/QToolBar>
39 #include <QtGui/QActionGroup>
43 #undef ENABLE_RAYTRACING
46 #ifdef ENABLE_RAYTRACING
48 #ifndef BALL_VIEW_RENDERING_RAYTRACINGRENDERER_H
49 # include <BALL/VIEW/RENDERING/raytracingRenderer.h>
52 # include <boost/shared_ptr.hpp>
53 #endif // ENABLE_RAYTRACING
66 class MaterialSettings;
67 class AnimationThread;
70 class TransformationEvent6D;
71 class MotionTrackingEvent;
122 #ifdef ENABLE_RAYTRACING
123 typedef boost::shared_ptr<RaytracingRenderer> RaytracingRendererPtr;
124 typedef boost::shared_ptr<t_RenderWindow> RaytracingWindowPtr;
170 ROTATE_CLOCKWISE_ACTION
212 Scene(
QWidget* parent_widget,
const char* name = NULL, Qt::WFlags w_flags = 0);
224 Scene (
const Scene& scene,
QWidget* parent_widget = NULL,
const char* name = NULL, Qt::WFlags wflags = 0);
238 virtual void clear();
249 void set(
const Scene& scene);
267 virtual void onNotify(
Message *message);
271 virtual bool exportScene(
Renderer &er)
const;
287 virtual void initializeWidget(
MainControl& main_control);
290 virtual void fetchPreferences(
INIFile& inifile);
293 virtual void writePreferences(
INIFile& inifile);
315 virtual bool isValid()
const;
323 virtual void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
334 void setCamera(
const Camera& camera);
337 std::list<Camera>& getAnimationPoints()
338 {
return animation_points_;}
341 static void setAnimationSmoothness(
float value)
342 { animation_smoothness_ = value;}
345 static float getAnimationSmoothness()
346 {
return animation_smoothness_;}
349 void setDefaultLighting(
bool update_GL =
true);
352 void initializePreferencesTab(
Preferences &preferences);
355 void finalizePreferencesTab(
Preferences &preferences);
358 virtual void applyPreferences();
361 static void setMouseSensitivity(
float sensitivity)
362 { mouse_sensitivity_ = sensitivity; }
365 static float getMouseSensitivity()
366 {
return mouse_sensitivity_;}
369 static void setMouseWheelSensitivity(
float sensitivity)
370 { mouse_wheel_sensitivity_ = sensitivity; }
373 static float getMouseWheelSensitivity()
374 {
return mouse_wheel_sensitivity_;}
377 static void setShowLightSources(
bool state)
378 { show_light_sources_ = state;}
381 static bool showLightSourcesEnabled()
382 {
return show_light_sources_;}
386 {
return *gl_renderer_;}
388 #ifdef ENABLE_RAYTRACING
390 RaytracingRenderer& getRaytracingRenderer()
391 {
return *rt_renderer_;}
401 static bool stereoBufferSupportTest();
410 bool exportPNG(
const String& filename);
413 virtual void setWidgetVisible(
bool state);
416 void setOffScreenRendering(
bool enabled,
Size factor);
419 virtual void paintEvent(QPaintEvent* e);
422 virtual void keyPressEvent(QKeyEvent* e);
425 virtual void mouseDoubleClickEvent(
QMouseEvent* e);
432 {
return current_mode_;}
435 virtual void setMode(ModeType mode);
438 virtual void projectionModeChanged();
450 void rotate(
float degree_right,
float degree_up);
453 void rotateClockwise(
float degree);
467 void moveComposites(
const std::list<Composite*>& composites,
Vector3 v);
474 void rotateComposites(
const std::list<Composite*>& composites,
float degree_right,
float degree_up,
float degree_clockwise = 0);
477 bool isAnimationRunning()
const;
486 void setFullScreen(
bool state);
494 void showText(
const String& text,
Size font_size = 20);
497 virtual void addToolBarEntries(QToolBar* tb);
505 bool inMoveMode()
const {
return (mouse_button_is_pressed_ && (getMode() == MOVE__MODE)); }
508 #ifdef ENABLE_RAYTRACING
509 void updateAllRTMaterials();
521 void createCoordinateSystem();
524 void createCoordinateSystemAtOrigin();
533 void exportNextPOVRay();
539 void showExportPNGDialog();
542 void showExportVRMLDialog();
553 virtual void switchShowWidget();
562 void enterActiveStereo();
565 void enterDualStereo();
568 void enterDualStereoDifferentDisplays();
571 void clearRecordedAnimation();
574 void startAnimation();
577 void stopAnimation();
580 void switchToLastMode();
583 void switchShowGrid();
589 void setupViewVolume();
592 void storeViewPoint();
595 void restoreViewPoint();
597 #ifdef ENABLE_RAYTRACING
598 RaytracingWindowPtr getWindow(WindowType aWindowType);
615 virtual void rotateMode_();
624 virtual void pickingMode_();
628 virtual void moveMode_();
631 virtual void showViewPoint_();
634 virtual void setViewPoint_();
637 virtual void resetCamera_();
642 virtual void resetRepresentationsForRenderer_(
RenderSetup& rs);
645 virtual void dropEvent(QDropEvent* e);
648 virtual void dragEnterEvent(QDragEnterEvent* e);
671 virtual void paintGL();
679 virtual void resizeEvent(QResizeEvent* event);
686 virtual void customEvent(
QEvent* evt);
712 virtual void mouseMoveEvent(
QMouseEvent* qmouse_event);
718 virtual void mousePressEvent(
QMouseEvent* qmouse_event);
724 virtual void mouseReleaseEvent(
QMouseEvent* qmouse_event);
729 virtual void wheelEvent(QWheelEvent* qmouse_event);
734 void processRotateModeMouseEvents_(
QMouseEvent* e);
737 void rotateSystem_();
738 void rotateSystemClockwise_();
739 void translateSystem_();
743 void selectionPressed_();
744 void selectionPressedMoved_();
746 void selectObjects_();
747 void pickParent_(QPoint p);
749 void writeLights_(
INIFile& inifile)
const;
751 void readLights_(
const INIFile& inifile);
753 inline float getXDiff_();
754 inline float getYDiff_();
757 void createCoordinateSystem_(
bool at_origin);
770 QAction *
no_stereo_action_, *active_stereo_action_, *dual_stereo_action_, *dual_stereo_different_display_action_;
803 #ifdef ENABLE_RAYTRACING
804 RaytracingRendererPtr rt_renderer_;
805 RaytracingWindowPtr rt_window_;
866 virtual void run() {scene_->animate_();}
869 void mySleep(
Size msec);
885 #endif // BALL_VIEW_WIDGETS_SCENE_H