From fdbf20c172ef5b48b70e38ff8094d5096fd0d2e2 Mon Sep 17 00:00:00 2001
From: Ozan Tonkal <ozantonkal@gmail.com>
Date: Sat, 7 Sep 2013 13:20:13 +0200
Subject: [PATCH] delete common.h, viz_types.hpp, rendering properties are
 public, setcolor in creating_widgets tutorial

---
 doc/tutorials/viz/viz.rst                     | 118 ------------------
 modules/viz/include/opencv2/viz/widgets.hpp   |  28 +++++
 modules/viz/src/common.h                      |  39 ------
 modules/viz/src/interactor_style.h            |   1 -
 modules/viz/src/precomp.hpp                   |   7 ++
 modules/viz/src/viz3d_impl.hpp                |   2 -
 modules/viz/src/viz_types.h                   |  12 --
 modules/viz/test/test_viz3d.cpp               |   5 +-
 .../tutorial_code/viz/creating_widgets.cpp    |   5 +-
 9 files changed, 43 insertions(+), 174 deletions(-)
 delete mode 100644 doc/tutorials/viz/viz.rst
 delete mode 100644 modules/viz/src/common.h
 delete mode 100644 modules/viz/src/viz_types.h

diff --git a/doc/tutorials/viz/viz.rst b/doc/tutorials/viz/viz.rst
deleted file mode 100644
index ceceaf1977..0000000000
--- a/doc/tutorials/viz/viz.rst
+++ /dev/null
@@ -1,118 +0,0 @@
-.. _viz:
-
-Launching Viz
-*************
-
-Goal
-====
-
-In this tutorial you will learn how to
-
-.. container:: enumeratevisibleitemswithsquare
-
-  * Open a visualization window.
-  * Access a window by its name.
-  * Start event loop.
-  * Start event loop for a given amount of time.
-
-Code
-====
-
-You can download the code from `here <../../../../samples/cpp/tutorial_code/viz/launching_viz.cpp>`_.
-
-.. code-block:: cpp
-
-    #include <opencv2/viz.hpp>
-    #include <iostream>
-
-    using namespace cv;
-    using namespace std;
-  
-    /**
-    * @function main
-    */
-    int main()
-    {
-        /// Create a window
-        viz::Viz3d myWindow("Viz Demo");
-        
-        /// Start event loop
-        myWindow.spin();
-        
-        /// Event loop is over when pressed q, Q, e, E
-        cout << "First event loop is over" << endl;
-        
-        /// Access window via its name
-        viz::Viz3d sameWindow = viz::get("Viz Demo");
-        
-        /// Start event loop
-        sameWindow.spin();
-        
-        /// Event loop is over when pressed q, Q, e, E
-        cout << "Second event loop is over" << endl;
-        
-        /// Event loop is over when pressed q, Q, e, E
-        /// Start event loop once for 1 millisecond
-        sameWindow.spinOnce(1, true);
-        while(!sameWindow.wasStopped())
-        {
-            /// Interact with window
-            
-            /// Event loop for 1 millisecond
-            sameWindow.spinOnce(1, true);
-        }
-        
-        /// Once more event loop is stopped
-        cout << "Last event loop is over" << endl;
-        return 0;
-    }
-    
-Explanation
-===========
-
-Here is the general structure of the program:
-
-* Create a window.
-
-.. code-block:: cpp
-
-    /// Create a window
-    viz::Viz3d myWindow("Viz Demo");
-    
-* Start event loop. This event loop will run until user terminates it by pressing **e**, **E**, **q**, **Q**.
-
-.. code-block:: cpp
-
-    /// Start event loop
-    myWindow.spin();
-    
-* Access same window via its name. Since windows are implicitly shared, **sameWindow** is exactly the same with **myWindow**. If the name does not exist, a new window is created.
-
-.. code-block:: cpp
-
-    /// Access window via its name
-    viz::Viz3d sameWindow = viz::get("Viz Demo");
-    
-* Start a controlled event loop. Once it starts, **wasStopped** is set to false. Inside the while loop, in each iteration, **spinOnce** is called to prevent event loop from completely stopping. Inside the while loop, user can execute other statements including those which interact with the window.
-
-.. code-block:: cpp
-
-    /// Event loop is over when pressed q, Q, e, E
-    /// Start event loop once for 1 millisecond
-    sameWindow.spinOnce(1, true);
-    while(!sameWindow.wasStopped())
-    {
-        /// Interact with window
-        
-        /// Event loop for 1 millisecond
-        sameWindow.spinOnce(1, true);
-    }
-    
-Results
-=======
-
-Here is the result of the program.
-
-.. image:: images/window_demo.png
-    :alt: Launching Viz
-    :align: center
diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp
index f96d0e6102..834af227d8 100644
--- a/modules/viz/include/opencv2/viz/widgets.hpp
+++ b/modules/viz/include/opencv2/viz/widgets.hpp
@@ -6,6 +6,34 @@ namespace cv
 {
     namespace viz
     {
+        /////////////////////////////////////////////////////////////////////////////
+        /// Widget rendering properties
+        enum RenderingProperties
+        {
+            VIZ_POINT_SIZE,
+            VIZ_OPACITY,
+            VIZ_LINE_WIDTH,
+            VIZ_FONT_SIZE,
+            VIZ_COLOR,
+            VIZ_REPRESENTATION,
+            VIZ_IMMEDIATE_RENDERING,
+            VIZ_SHADING
+        };
+
+        enum RenderingRepresentationProperties
+        {
+            REPRESENTATION_POINTS,
+            REPRESENTATION_WIREFRAME,
+            REPRESENTATION_SURFACE
+        };
+
+        enum ShadingRepresentationProperties
+        {
+            SHADING_FLAT,
+            SHADING_GOURAUD,
+            SHADING_PHONG
+        };
+        
         /////////////////////////////////////////////////////////////////////////////
         /// The base class for all widgets
         class CV_EXPORTS Widget
diff --git a/modules/viz/src/common.h b/modules/viz/src/common.h
deleted file mode 100644
index 7e13b0fee3..0000000000
--- a/modules/viz/src/common.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-#include <opencv2/core/cvdef.h>
-#include <opencv2/core.hpp>
-#include <opencv2/viz/types.hpp>
-
-namespace cv
-{
-    namespace viz
-    {
-        enum RenderingProperties
-        {
-            VIZ_POINT_SIZE,
-            VIZ_OPACITY,
-            VIZ_LINE_WIDTH,
-            VIZ_FONT_SIZE,
-            VIZ_COLOR,
-            VIZ_REPRESENTATION,
-            VIZ_IMMEDIATE_RENDERING,
-            VIZ_SHADING
-        };
-
-        enum RenderingRepresentationProperties
-        {
-            REPRESENTATION_POINTS,
-            REPRESENTATION_WIREFRAME,
-            REPRESENTATION_SURFACE
-        };
-
-        enum ShadingRepresentationProperties
-        {
-            SHADING_FLAT,
-            SHADING_GOURAUD,
-            SHADING_PHONG
-        };
-
-    }
-
-}
diff --git a/modules/viz/src/interactor_style.h b/modules/viz/src/interactor_style.h
index aba03a373d..e48eb3d2ca 100644
--- a/modules/viz/src/interactor_style.h
+++ b/modules/viz/src/interactor_style.h
@@ -1,6 +1,5 @@
 #pragma once
 
-#include "viz_types.h"
 #include <opencv2/viz/types.hpp>
 
 namespace cv
diff --git a/modules/viz/src/precomp.hpp b/modules/viz/src/precomp.hpp
index 9dafeecc8f..b2a26b5412 100644
--- a/modules/viz/src/precomp.hpp
+++ b/modules/viz/src/precomp.hpp
@@ -76,6 +76,13 @@
 #undef __DEPRECATED_DISABLED__
 #endif
 
+namespace cv
+{
+    namespace viz
+    {
+        typedef std::map<std::string, vtkSmartPointer<vtkProp> > WidgetActorMap;
+    }
+}
 
 #include "viz3d_impl.hpp"
 #include <opencv2/core.hpp>
diff --git a/modules/viz/src/viz3d_impl.hpp b/modules/viz/src/viz3d_impl.hpp
index 7e31501ed0..b6986b20c3 100644
--- a/modules/viz/src/viz3d_impl.hpp
+++ b/modules/viz/src/viz3d_impl.hpp
@@ -2,8 +2,6 @@
 
 #include <opencv2/viz.hpp>
 #include "interactor_style.h"
-#include "viz_types.h"
-#include "common.h"
 
 struct cv::viz::Viz3d::VizImpl
 {
diff --git a/modules/viz/src/viz_types.h b/modules/viz/src/viz_types.h
deleted file mode 100644
index 33de56af33..0000000000
--- a/modules/viz/src/viz_types.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-
-#include "precomp.hpp"
-
-namespace cv
-{
-    namespace viz
-    {
-        typedef std::map<std::string, vtkSmartPointer<vtkProp> > WidgetActorMap;
-    }
-}
-
diff --git a/modules/viz/test/test_viz3d.cpp b/modules/viz/test/test_viz3d.cpp
index d8dbb64cac..5e9d13c7bb 100644
--- a/modules/viz/test/test_viz3d.cpp
+++ b/modules/viz/test/test_viz3d.cpp
@@ -44,6 +44,7 @@
 #include <opencv2/core.hpp>
 #include <opencv2/imgproc.hpp>
 #include <opencv2/highgui.hpp>
+#include <opencv2/calib3d.hpp>
 
 #include <fstream>
 #include <string>
@@ -100,6 +101,7 @@ TEST(Viz_viz3d, accuracy)
     viz::CoordinateSystemWidget csw;
     viz::TextWidget tw("TEST", Point(100, 100), 20);
     viz::CloudWidget pcw(cloud, colors);
+//     pcw.setRenderingProperty(VIZ_LINE_WIDTH));
     viz::CloudWidget pcw2(cloud, viz::Color::magenta());
     
 //     viz.showWidget("line", lw);
@@ -135,7 +137,7 @@ TEST(Viz_viz3d, accuracy)
     
     viz::Mesh3d mesh = cv::viz::Mesh3d::loadMesh("/Users/nerei/horse.ply");
     
-    viz::MeshWidget mw(mesh);
+//     viz::MeshWidget mw(mesh);
 //     viz.showWidget("mesh", mw);
     
     Mat img = imread("opencv.png");
@@ -173,6 +175,7 @@ TEST(Viz_viz3d, accuracy)
     //viz.showWidget("trajectory1", viz::TrajectoryWidget(trajectory, viz::Color(0,255,255), true, 0.5));
     viz.showWidget("trajectory2", viz::TrajectoryWidget(trajectory, K, 1.0, viz::Color(255,0,255)));
     
+//     cv::Rodrigues2(Vec3f(), Mat());
     
     
 //     viz.showWidget("trajectory1", viz::TrajectoryWidget(trajectory/*, viz::Color::yellow()*/));
diff --git a/samples/cpp/tutorial_code/viz/creating_widgets.cpp b/samples/cpp/tutorial_code/viz/creating_widgets.cpp
index 1c0f9a34ea..9d2b5a3130 100644
--- a/samples/cpp/tutorial_code/viz/creating_widgets.cpp
+++ b/samples/cpp/tutorial_code/viz/creating_widgets.cpp
@@ -81,6 +81,9 @@ TriangleWidget::TriangleWidget(const Point3f &pt1, const Point3f &pt2, const Poi
     
     // Store this actor in the widget in order that visualizer can access it
     viz::WidgetAccessor::setProp(*this, actor);
+    
+    // Set the color of the widget. This has to be called after WidgetAccessor.
+    setColor(color);
 }
 
 /**
@@ -94,7 +97,7 @@ int main()
     viz::Viz3d myWindow("Creating Widgets");
     
     /// Create a triangle widget
-    TriangleWidget tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0));
+    TriangleWidget tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
     
     /// Show widget in the visualizer window
     myWindow.showWidget("TRIANGLE", tw);
-- 
2.18.0