[Gcblue-commits] gcb_wx/include/graphics tc3DWindow.h,NONE,1.1 tcGraphicsEngine.h,1.12,1.13 tcMapObj
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-09-14 02:02:33
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14891/include/graphics Modified Files: tcGraphicsEngine.h tcMapObject.h tcWindow.h Added Files: tc3DWindow.h Log Message: Index: tcWindow.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcWindow.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcWindow.h 8 Aug 2004 00:31:32 -0000 1.5 --- tcWindow.h 14 Sep 2004 02:01:45 -0000 1.6 *************** *** 86,89 **** --- 86,90 ---- void MoveToTop(); ///< moves window to top void MoveWindow(int ax, int ay); + wxRealPoint RelativeToScreen(float x, float y); void SetBackground(UINT32 anColor); --- NEW FILE: tc3DWindow.h --- /** ** @file tc3DWindow.h */ /* Copyright (C) 2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TC3DWINDOW_H_ #define _TC3DWINDOW_H_ #if _MSC_VER > 1000 #pragma once #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include <vector> #include <osg/ref_ptr> #include "common/simmath.h" namespace osg { class ClipNode; class DrawPixels; class Geode; class Geometry; class MatrixTransform; class Projection; class Texture2D; } namespace osgText { class Font; class Text; } class tcGraphicsEngine; class tc3DViewer; #define IMAGE_PATH "images\\" /** * Window class for drawing to a 3D OSG scenegraph. * This is intended as a cross-platform replacement for tc3DWindow. * tc3DWindow heavily used the Windows GDI+ libary. */ class tc3DWindow : public wxWindow { public: bool mbActive; tcRect mrectDisplay; void AddChild(tc3DWindow* child); bool IsBackgroundLoaded(); // {return mpiBackground != NULL;} virtual int Draw(); virtual void DrawChildren(); // virtual void DrawChildren(Gdiplus::Graphics *graphics); void DrawBorder(); void DrawImage(osg::Texture2D* texture, float x, float y, float width, float height); void DrawLine(float x1, float y1, float x2, float y2, const osg::Vec4& color); void DrawText(const char* s, float x, float y, osgText::Font* font, const osg::Vec4& color, float fontSize, osgText::Text::AlignmentType alignment); void DrawText(osgText::Font* font, const osg::Vec4& color, float fontSize, const char* s, float x, float y, tcRect& r); // returns bounding box in r void DrawTextInRect(osgText::Font* font, const osg::Vec4& color, const char* s, tcRect& rect); void DrawTextInRectWrap(osgText::Font* font, const osg::Vec4& color, const char* s, tcRect& rect); void MeasureText(osgText::Font* font, const char* s, wxSize& size); void Erase(); void EraseOpaque(); virtual void Freeze(); bool IsActive() const {return mbActive;} bool IsBackgroundEnabled() const; bool IsSurfaceModified(); virtual bool IsWindowMinimized() const; void LoadBackgroundImage(char* fileName); osg::Image* LoadImage(const char* fileName); virtual void Maximize(); virtual void Minimize(); void MoveToTop(); ///< moves window to top void MoveWindow(int ax, int ay); wxRealPoint RelativeToScreen(float x, float y); void SetBackground(UINT32 anColor); bool GetBlend(); void SetBlend(bool blendingOn); void SetOpaque(); void SetPixel(int x, int y, unsigned int value); void SetDisplayRegion(tcRect r); virtual void SetActive(bool abActive); void SetBackgroundDraw(bool state); void SetResizeable2D(bool abState) {resizeable2DSurface = abState;} ///< @see tc3DWindow::OnSize virtual void SetYMirror(int y) {yMirror = y;} virtual void Thaw(); static void Set3DViewer(tc3DViewer* aviewer) {viewer = aviewer;} tc3DWindow(wxWindow* parent, const wxPoint& pos, const wxSize& size, const wxString& name = "tc3DWindow"); virtual ~tc3DWindow(); protected: std::vector<tc3DWindow*> children; wxRect mrectWindow; // location for map in back buffer int mnWidth; ///< window dimension--tried to make const, but problem in tcTerrainView int mnHeight; int yMirror; ///< workaround for opposite y directions of OpenGL vs. wxWindows /// true if 2DSurface should be resized with window, normally false for zoomed surfaces /// such as with the tcTerrainView /// @see tc3DWindow::OnSize view OnSize method code to see how this is used bool resizeable2DSurface; osg::ref_ptr<osgText::Font> defaultFont; osg::ref_ptr<osg::Texture2D> backgroundTexture; osg::ref_ptr<osg::Geometry> backgroundQuad; osg::ref_ptr<osg::Texture2D> defaultTexture; osg::ref_ptr<osg::Texture2D> testSymbol; bool mbCloned; bool mbFrozen; wxRect normalPosition; ///< normal, non-minimized pos of window wxRect iconPosition; ///< minimized, icon pos of window const int iconSize; static tc3DViewer* viewer; wxString PrependImagePath(const char* fileName); virtual void OnChar(wxKeyEvent& event); virtual void OnEnterWindow(wxMouseEvent& event); void OnEraseBackground(wxEraseEvent& event); virtual void OnKeyDown(wxKeyEvent& event); virtual void OnKillFocus(wxFocusEvent& event); virtual void OnLButtonDown(wxMouseEvent& event); virtual void OnLButtonUp(wxMouseEvent& event); virtual void OnLeaveWindow(wxMouseEvent& event); virtual void OnMouseMove(wxMouseEvent& event); virtual void OnMouseWheel(wxMouseEvent& event); virtual void OnMove(wxMoveEvent& event); void OnPaint(wxPaintEvent& event); virtual void OnRButtonDown(wxMouseEvent& event); virtual void OnSetFocus(wxFocusEvent& event); virtual void OnShow(wxShowEvent& event); virtual void OnSize(wxSizeEvent& event); void SkipMouseEvent(wxMouseEvent& event); ///< adjusts position to parent frame long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); private: osg::ref_ptr<osg::ClipNode> clipNode; osg::ref_ptr<osg::Geode> root; ///< root node for drawables osg::ref_ptr<osg::MatrixTransform> transform; ///< transform node for 3D draw objects, child of projection osg::ref_ptr<osg::Projection> projection; /* eventually refactor this to use a template vs. recoding ** a new pool system for each different object type */ std::vector<osg::ref_ptr<osgText::Text> > textPool; unsigned int textIdx; std::vector<osg::ref_ptr<osg::Geometry> > imageQuadPool; unsigned int imageQuadIdx; std::vector<osg::ref_ptr<osg::Geometry> > linePool; unsigned int lineIdx; osgText::Text::AlignmentType LEFT_BASE_LINE; osgText::Text::AlignmentType CENTER_CENTER; void CreateBackgroundQuad(); void UpdateBackgroundQuadVertices(); osg::Geometry* GetImageQuadObject(); osg::Geometry* GetLineObject(); osgText::Text* GetTextObject(); void HideUnusedObjects(); void InitGraphicsObjects(); DECLARE_EVENT_TABLE() }; #endif Index: tcMapObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMapObject.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcMapObject.h 1 Sep 2004 02:55:35 -0000 1.5 --- tcMapObject.h 14 Sep 2004 02:01:45 -0000 1.6 *************** *** 68,83 **** void SetActive(bool active) {isActive = active;} void SetColor(UINT32 argbColor) {color = argbColor;} static void SetMapView(MapView::tcMapView *mv); tcMapObject(); ! tcMapObject(double lon_deg, double lat_deg); virtual ~tcMapObject(); protected: tcPoint GetScreenPoint() const; static MapView::tcMapView *mapView; ///< used to translate lat/lon coords into screen coords private: ! double lat_rad; ///< radian latitude ! double lon_rad; ///< radian longitude }; --- 68,88 ---- void SetActive(bool active) {isActive = active;} void SetColor(UINT32 argbColor) {color = argbColor;} + void SetMarkerActive(bool active) {markerEnabled = active;} + void SetUseScreenCoords(bool active) {useRelativeCoords = active;} static void SetMapView(MapView::tcMapView *mv); tcMapObject(); ! tcMapObject(double x, double y, bool useRel = false); virtual ~tcMapObject(); protected: + bool markerEnabled; ///< true to draw X marker with text + tcPoint GetScreenPoint() const; static MapView::tcMapView *mapView; ///< used to translate lat/lon coords into screen coords private: ! bool useRelativeCoords; ///< interpret lat_rad and lon_rad as rel screen coords [0-1] ! double _x; ///< radian latitude or relative screen x coord ! double _y; ///< radian longitude or relative screen y coord }; *************** *** 93,97 **** tcMapTextObject(); ! tcMapTextObject(std::string text, double lon_deg, double lat_deg); virtual ~tcMapTextObject(); }; --- 98,102 ---- tcMapTextObject(); ! tcMapTextObject(std::string text, double x, double y, bool useRel = false); virtual ~tcMapTextObject(); }; Index: tcGraphicsEngine.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcGraphicsEngine.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcGraphicsEngine.h 8 Aug 2004 00:31:32 -0000 1.12 --- tcGraphicsEngine.h 14 Sep 2004 02:01:45 -0000 1.13 *************** *** 51,54 **** --- 51,58 ---- #define MAX_TEXTURES 10 + namespace osg + { + class MatrixTransform; + } typedef tc2DGraphicsSurface* tp2DSurface; *************** *** 109,113 **** void LogPixelFormats(); bool MoveSurfaceToTop(tc2DGraphicsSurface* ap2DSurface); ! bool RenderAll(void); void ToggleBlending() {mbBlend = !mbBlend;} void ToggleTexture2D() {mbTexture2D = !mbTexture2D;} --- 113,117 ---- void LogPixelFormats(); bool MoveSurfaceToTop(tc2DGraphicsSurface* ap2DSurface); ! bool RenderAll(); void ToggleBlending() {mbBlend = !mbBlend;} void ToggleTexture2D() {mbTexture2D = !mbTexture2D;} |