diff Samples/Qt/BasicScene.cpp @ 885:56e4e9281076 am-dev

sharing code between Qt/SDL BasiceScene sample
author Alain Mazy <alain@mazy.be>
date Tue, 09 Jul 2019 16:44:25 +0200
parents 30268a0cafca
children 6073c980323a
line wrap: on
line diff
--- a/Samples/Qt/BasicScene.cpp	Tue Jul 09 14:43:00 2019 +0200
+++ b/Samples/Qt/BasicScene.cpp	Tue Jul 09 16:44:25 2019 +0200
@@ -51,99 +51,11 @@
 #include <QDebug>
 #include <QWindow>
 
-static const unsigned int FONT_SIZE = 32;
-static const int LAYER_POSITION = 150;
+#include "../Shared/SharedBasicScene.h"
+
 
 using namespace OrthancStone;
 
-void PrepareScene(boost::shared_ptr<OrthancStone::ViewportController> controller)
-{
-  Scene2D& scene(*controller->GetScene());
-  // Texture of 2x2 size
-  {
-    Orthanc::Image i(Orthanc::PixelFormat_RGB24, 2, 2, false);
-    
-    uint8_t *p = reinterpret_cast<uint8_t*>(i.GetRow(0));
-    p[0] = 255;
-    p[1] = 0;
-    p[2] = 0;
-
-    p[3] = 0;
-    p[4] = 255;
-    p[5] = 0;
-
-    p = reinterpret_cast<uint8_t*>(i.GetRow(1));
-    p[0] = 0;
-    p[1] = 0;
-    p[2] = 255;
-
-    p[3] = 255;
-    p[4] = 0;
-    p[5] = 0;
-
-    scene.SetLayer(12, new ColorTextureSceneLayer(i));
-
-    std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
-    l->SetOrigin(-3, 2);
-    l->SetPixelSpacing(1.5, 1);
-    l->SetAngle(20.0 / 180.0 * 3.14);
-    scene.SetLayer(14, l.release());
-  }
-
-  // Texture of 1x1 size
-  {
-    Orthanc::Image i(Orthanc::PixelFormat_RGB24, 1, 1, false);
-    
-    uint8_t *p = reinterpret_cast<uint8_t*>(i.GetRow(0));
-    p[0] = 255;
-    p[1] = 0;
-    p[2] = 0;
-
-    std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
-    l->SetOrigin(-2, 1);
-    l->SetAngle(20.0 / 180.0 * 3.14);
-    scene.SetLayer(13, l.release());
-  }
-
-  // Some lines
-  {
-    std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer);
-
-    layer->SetThickness(1);
-
-    PolylineSceneLayer::Chain chain;
-    chain.push_back(ScenePoint2D(0 - 0.5, 0 - 0.5));
-    chain.push_back(ScenePoint2D(0 - 0.5, 2 - 0.5));
-    chain.push_back(ScenePoint2D(2 - 0.5, 2 - 0.5));
-    chain.push_back(ScenePoint2D(2 - 0.5, 0 - 0.5));
-    layer->AddChain(chain, true, 255, 0, 0);
-
-    chain.clear();
-    chain.push_back(ScenePoint2D(-5, -5));
-    chain.push_back(ScenePoint2D(5, -5));
-    chain.push_back(ScenePoint2D(5, 5));
-    chain.push_back(ScenePoint2D(-5, 5));
-    layer->AddChain(chain, true, 0, 255, 0);
-
-    double dy = 1.01;
-    chain.clear();
-    chain.push_back(ScenePoint2D(-4, -4));
-    chain.push_back(ScenePoint2D(4, -4 + dy));
-    chain.push_back(ScenePoint2D(-4, -4 + 2.0 * dy));
-    chain.push_back(ScenePoint2D(4, 2));
-    layer->AddChain(chain, false, 0, 0, 255);
-
-//    layer->SetColor(0,255, 255);
-    scene.SetLayer(50, layer.release());
-  }
-
-  // Some text
-  {
-    std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
-    layer->SetText("Hello");
-    scene.SetLayer(100, layer.release());
-  }
-}
 
 
 static void GLAPIENTRY OpenGLMessageCallback(GLenum source,
@@ -166,7 +78,6 @@
 
 #include <QApplication>
 #include "BasicSceneWindow.h"
-#include "Scene2DInteractor.h"
 
 int main(int argc, char* argv[])
 {
@@ -195,7 +106,7 @@
 
     boost::shared_ptr<OpenGLCompositor> compositor = boost::make_shared<OpenGLCompositor>(window.GetOpenGlWidget(), *controller->GetScene());
     compositor->SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT,
-                       FONT_SIZE, Orthanc::Encoding_Latin1);
+                       BASIC_SCENE_FONT_SIZE, Orthanc::Encoding_Latin1);
 
     interactor->SetCompositor(compositor);
     window.GetOpenGlWidget().SetCompositor(compositor);