NCBI C++ ToolKit
glpanewidget_child_demo.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: glpanewidget_child_demo.cpp 42140 2018-12-27 19:19:17Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  */
30 
31 #include <ncbi_pch.hpp>
32 
34 #include "glpanewidget_demo.hpp"
35 
36 #include <gui/opengl/irender.hpp>
37 
39 
40 BEGIN_EVENT_TABLE(CGlPaneWidgetChildDemo, CGlWidgetPane)
43 
44 
46 : CGlWidgetPane(parent, id, wxDefaultPosition, wxDefaultSize, 0),
47  m_Pane(CGlPane::eAlwaysUpdate)
48 {
49  SetBackgroundColour(wxColour(230, 230, 255));
50 
51  m_MouseZoomHandler.SetHost(static_cast<IMouseZoomHandlerHost*>(this));
52  x_RegisterHandler(&m_MouseZoomHandler, 0xFFFF, &m_Pane);
53 
54  m_HorzSelHandler.SetHost(static_cast<ISelHandlerHost*>(this));
55  x_RegisterHandler(&m_HorzSelHandler, 0xFFFF, &m_Pane);
56 }
57 
58 
60 {
61 }
62 
63 
65 {
66  return TVPPoint(1000, 1000);
67 }
68 
69 
71 {
73 
74  IRender& gl = GetGl();
75 
76  // clear background
77  wxSize size = GetClientSize();
78  int h = size.GetHeight();
79  int w = size.GetWidth();
80 
81  gl.Viewport(0, 0, w, h);
82 
83  // Render graphics
84  CGlWidgetDemo* the_parent = dynamic_cast<CGlWidgetDemo*>(GetParent());
85  m_Pane = the_parent->GetPort();
86 
87  m_Pane.OpenOrtho();
88 
89  gl.Color3d(1.0, 0.0, 0.0);
90  gl.Rectd(0.0, 0.0, 10.0, 10.0);
91 
92  gl.Color3d(0.0, 1.0, 0.0);
93  gl.Rectd(10.0, 10.0, 20.0, 20.0);
94 
95  gl.Color3d(0.0, 0.0, 1.0);
96  gl.Rectd(20.0, 20.0, 30.0, 30.0);
97 
98  m_Pane.Close();
99 
101 }
102 
103 
105 {
106  glEnable(GL_BLEND);
107  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
108 
111 
112  glDisable(GL_BLEND);
113 }
114 
115 
117 {
118  return dynamic_cast<CGlWidgetDemo*>(GetParent());
119 }
120 
121 
122 void CGlPaneWidgetChildDemo::OnSize(wxSizeEvent& WXUNUSED(event))
123 {
124  m_Pane = x_GetParent()->GetPort();
125 }
126 
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// ISelHandlerHost implementation
131 {
132  //CEvent evt(CEvent::eEvent_Message, CViewEvent::eWidgetSelectionChanged);
133  //Send(&evt, ePool_Parent);
134  Refresh();
135 }
136 
137 
139 {
140  switch(orient) {
141  case eHorz:
142  return m_Pane.UnProjectX(z);
143  case eVert:
144  return m_Pane.UnProjectY(GetSize().y - z);
145  default:
146  _ASSERT(false); return -1;
147  }
148 }
149 
150 
152 {
153  switch(orient) {
154  case eHorz:
155  return m_Pane.ProjectX(z);
156  case eVert:
157  return GetSize().y - m_Pane.ProjectY(z);
158  default:
159  _ASSERT(false); return -1;
160  }
161 }
162 
163 
164 ////////////////////////////////////////////////////////////////////////////////
165 /// IMouseZoomHandlerHost implementation
166 
168 {
169  const CGlPane& VP = x_GetParent()->GetPort();
170 
171  switch(type) {
172  case eCurrent:
173  return VP.GetScaleX();
174  case eMin:
175  return VP.GetMinScaleX();
176  case eMax:
177  return VP.GetZoomAllScaleX();
178  default:
179  _ASSERT(false); return -1;
180  }
181 }
182 
183 
185 {
186  x_GetParent()->SetScale(scale, point);
187 }
188 
189 
191 {
192  x_GetParent()->ZoomRect(rc);
193 
194  // translate the notification to the standard message
196 }
197 
198 
200 {
201  x_GetParent()->ZoomPoint(point, factor);
202 
203  // translate the notification to the standard message
205 }
206 
207 
209 {
210  // translate the notification to the standard message
212 }
213 
214 
216 {
217  x_GetParent()->Scroll(d_x, d_y);
218 
219  // translate the notification to the standard message
221 }
222 
223 
225 {
226  return GetSize().y - 1 - y;
227 }
228 
229 
virtual void x_Render()
Definition: glcanvas.cpp:316
virtual TVPPoint GetPortSize()
CGlWidgetPane overridables.
virtual void MZHH_Scroll(TModelUnit d_x, TModelUnit d_y)
CMouseZoomHandler m_MouseZoomHandler
void OnSize(wxSizeEvent &event)
virtual TVPUnit SHH_GetWindowByModel(TModelUnit z, EOrientation orient)
virtual void x_Render()
CGlWidgetPane overridables.
virtual TModelUnit MZHH_GetScale(EScaleType type)
IMouseZoomHandlerHost implementation.
virtual TVPUnit MZHH_GetVPPosByY(int y) const
converts window coord to Viewport coord
virtual TModelUnit SHH_GetModelByWindow(int z, EOrientation orient)
virtual void SHH_OnChanged()
ISelHandlerHost implementation.
virtual void MZHH_ZoomPoint(const TModelPoint &point, TModelUnit factor)
virtual void MZHH_ZoomRect(const TModelRect &rc)
virtual void MZHH_SetScale(TModelUnit scale, const TModelPoint &point)
class CGlPane
Definition: glpane.hpp:62
virtual void Scroll(TModelUnit d_x, TModelUnit d_y)
virtual void NotifyVisibleRangeChanged()
virtual void ZoomRect(const TModelRect &rc)
virtual void ZoomPoint(const TModelPoint &point, TModelUnit factor, CGlPane::EZoomOptions=CGlPane::fZoomXY)
CGlWidgetDemo.
virtual CGlPane & GetPort()
implement these 2 functions in derived classes
virtual void SetScale(TModelUnit scale, const TModelPoint &point)
CGlWidgetPane represent a window component residing in CGlWidgetBase client area.
void Render(CGlPane &Pane, ERenderingOption option=eActiveState)
virtual void Render(CGlPane &Pane)
Interface IMouseZoomHandlerHost represents a context in which CMouseZoomHandler functions.
class ISelHandlerHost
GLdouble TModelUnit
Definition: gltypes.hpp:48
virtual void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)=0
bool OpenOrtho()
Definition: glpane.hpp:427
CGlPoint< TVPUnit > TVPPoint
Definition: gltypes.hpp:50
TVPUnit ProjectX(TModelUnit m_x) const
Definition: glpane.cpp:661
void Color3d(GLdouble r, GLdouble g, GLdouble b)
Definition: irender.hpp:100
IRender & GetGl()
convenience function for getting current render manager
TVPUnit ProjectY(TModelUnit m_y) const
Definition: glpane.cpp:676
TModelUnit UnProjectX(TVPUnit m_x) const
Definition: glpane.cpp:706
void Close(void)
Definition: glpane.cpp:178
TModelUnit UnProjectY(TVPUnit m_y) const
Definition: glpane.cpp:722
int TVPUnit
Definition: gltypes.hpp:47
TModelUnit GetZoomAllScaleX(void) const
Definition: glpane.cpp:133
TModelUnit GetMinScaleX(void) const
Definition: glpane.hpp:452
TModelUnit GetScaleX(void) const
Definition: glpane.cpp:118
void Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
Definition: irender.hpp:193
EOrientation
Definition: gltypes.hpp:58
@ eHorz
Definition: gltypes.hpp:59
@ eVert
Definition: gltypes.hpp:60
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
Definition: type.c:6
#define _ASSERT
Modified on Fri Sep 20 14:58:02 2024 by modify_doxy.py rev. 669887