layered_figure.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Software License Agreement (BSD License) *
3  * Copyright (C) 2016 by Horatiu George Todoran <todorangrg@gmail.com> *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions *
7  * are met: *
8  * *
9  * 1. Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * 2. Redistributions in binary form must reproduce the above copyright *
12  * notice, this list of conditions and the following disclaimer in *
13  * the documentation and/or other materials provided with the *
14  * distribution. *
15  * 3. Neither the name of the copyright holder nor the names of its *
16  * contributors may be used to endorse or promote products derived *
17  * from this software without specific prior written permission. *
18  * *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY *
29  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
30  * POSSIBILITY OF SUCH DAMAGE. *
31  ***************************************************************************/
32 
34 
35 #include <opencv2/core/core.hpp>
36 #include <opencv2/core/core_c.h>
37 #include <opencv2/opencv.hpp>
38 #include <opencv/cv.hpp>
39 
40 using namespace cv;
41 using namespace std;
42 using namespace tuw;
43 
44 
45 
46 LayeredFigure::LayeredFigure( const std::string &_title ) : Figure(_title), view_idx_(0), sizeLayers_(0) {
47  namedWindow( title(), CV_WINDOW_AUTOSIZE | CV_GUI_EXPANDED);
48  std::string namet1 = "MapLayer";
49 
50 // cv::setMouseCallback ( title(), GlobalInterface::onMouseMap, this );
51  createTrackbar( namet1, title(), &view_idx_, layeredMaps.sizeLayers()+1, LayeredFigure::callbackTrkbar1 );
52 }
53 
54 void LayeredFigure::callbackTrkbar1( int flags, void* param ) {
55 
56 }
57 
58 void LayeredFigure::init ( int width_pixel, int height_pixel,
59  double min_y, double max_y,
60  double min_x, double max_x, double rotation,
61  double grid_scale_x, double grid_scale_y, const string& background_image ) {
62  tuw::Figure::init ( width_pixel, height_pixel, min_y, max_y, min_x, max_x, rotation, grid_scale_x, grid_scale_y, background_image );
63  layeredMaps.initLayers(width_pixel, height_pixel, min_y, max_y, min_x, max_x, rotation);
64 
67  destroyWindow(title());
68  namedWindow( title(), CV_WINDOW_AUTOSIZE | CV_GUI_EXPANDED);
69  std::string namet1 = "MapLayer";
70  createTrackbar( namet1, title(), &view_idx_, sizeLayers_, LayeredFigure::callbackTrkbar1 );
71  }
72 }
73 
75  if(view_idx_>0) {
76 // setView(layeredMaps.mapLayer(view_idx_-1));
78  }
79  imshow ( title(), view() );
80 // switch (view_idx_) {
81 // case (0): imshow ( title(), view() ); break;
82 // default : imshow ( title(), layeredMaps.mapLayer(view_idx_-1) ); break;
83 // }
84  waitKey( 10 );
85  clear();
86 }
87 
static const cv::Scalar black
Definition: figure.h:200
void init()
initializes the transformation matrices
void initLayers(int width_pixel, int height_pixel, double min_x, double max_x, double min_y, double max_y, double rotation=0)
void appendToView(const cv::Mat &_mat, const cv::Scalar &_colMin, const cv::Scalar &_colMax, u_int8_t _truncateLayerVal=0)
Definition: figure.cpp:180
Definition: point2d.h:208
LayeredMaps layeredMaps
cv::Mat & mapLayer(const size_t &_layer)
size_t sizeLayers() const
Definition: command.h:8
static const cv::Scalar white
Definition: figure.h:201
void clear()
Definition: figure.cpp:138
static void callbackTrkbar1(int flags, void *param)
const std::string title() const
Definition: figure.cpp:156
const cv::Mat & view() const
Definition: figure.cpp:55


tuw_geometry
Author(s): Markus Bader
autogenerated on Mon Jun 10 2019 15:33:08