[GRASS-SVN] r35803 - in grass/branches/develbranch_6/gui/wxpython: gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 8 09:49:46 EST 2009


Author: martinl
Date: 2009-02-08 09:49:46 -0500 (Sun, 08 Feb 2009)
New Revision: 35803

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
   grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp
   grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h
   grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
   grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
   grass/branches/develbranch_6/gui/wxpython/vdigit/pseudodc.i
Log:
wxGUI: use local pseudoDC class (if not available switch to wx.PseudoDC)
       (merge from trunk, r35802)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2009-02-08 14:43:28 UTC (rev 35802)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2009-02-08 14:49:46 UTC (rev 35803)
@@ -33,6 +33,7 @@
 from vdigit import VDigitCategoryDialog
 from vdigit import VDigitZBulkDialog
 from vdigit import VDigitDuplicatesDialog
+from vdigit import PseudoDC
 
 class MapWindow(object):
     """
@@ -217,13 +218,13 @@
         ### self.OnSize(None)
 
         # create PseudoDC used for background map, map decorations like scales and legends
-        self.pdc = wx.PseudoDC()
+        self.pdc = PseudoDC()
         # used for digitization tool
         self.pdcVector = None
         # decorations (region box, etc.)
-        self.pdcDec = wx.PseudoDC()
+        self.pdcDec = PseudoDC()
         # pseudoDC for temporal objects (select box, measurement tool, etc.)
-        self.pdcTmp = wx.PseudoDC()
+        self.pdcTmp = PseudoDC()
         # redraw all pdc's, pdcTmp layer is redrawn always (speed issue)
         self.redrawAll = True
 
@@ -283,8 +284,8 @@
         if pdctype == 'image': # draw selected image
             bitmap = wx.BitmapFromImage(img)
             w,h = bitmap.GetSize()
-            pdc.DrawBitmap(bitmap, coords[0], coords[1], True) # draw the composite map
-            pdc.SetIdBounds(drawid, (coords[0],coords[1], w, h))
+            pdc.DrawBitmap(bitmap, wx.Point(coords[0], coords[1]), True) # draw the composite map
+            pdc.SetIdBounds(drawid, wx.Rect(coords[0],coords[1], w, h))
 
         elif pdctype == 'box': # draw a box on top of the map
             if self.pen:
@@ -298,22 +299,30 @@
                 rheight = y2-y1
                 rect = wx.Rect(x1,y1,rwidth,rheight)
                 pdc.DrawRectangleRect(rect)
-                pdc.SetIdBounds(drawid,rect)
+                pdc.SetIdBounds(drawid, rect)
                 # self.ovlcoords[drawid] = coords
 
         elif pdctype == 'line': # draw a line on top of the map
             if self.pen:
                 pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
                 pdc.SetPen(self.pen)
-                pdc.DrawLine(coords[0], coords[1], coords[2], coords[3])
-                pdc.SetIdBounds(drawid,(coords[0], coords[1], coords[2], coords[3]))
+                pdc.DrawLine(wx.Point(coords[0], coords[1]),
+                             wx.Point(coords[2], coords[3]))
+                pdc.SetIdBounds(drawid, wx.Rect(coords[0], coords[1], coords[2], coords[3]))
                 # self.ovlcoords[drawid] = coords
 
         elif pdctype == 'polyline': # draw a polyline on top of the map
             if self.polypen:
                 pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
                 pdc.SetPen(self.polypen)
-                pdc.DrawLines(coords)
+                ### pdc.DrawLines(coords)
+                if (len(coords) < 2):
+                    return
+                i = 1
+                while i < len(coords):
+                    pdc.DrawLine(wx.Point(coords[i-1][0], coords[i-1][1]),
+                                 wx.Point(coords[i][0], coords[i][1]))
+                    i += 1
 
                 # get bounding rectangle for polyline
                 xlist = []
@@ -327,7 +336,7 @@
                     x2=max(xlist)
                     y1=min(ylist)
                     y2=max(ylist)
-                    pdc.SetIdBounds(drawid,(x1,y1,x2,y2))
+                    pdc.SetIdBounds(drawid, wx.Rect(x1,y1,x2,y2))
                     # self.ovlcoords[drawid] = [x1,y1,x2,y2]
 
         elif pdctype == 'point': # draw point
@@ -338,7 +347,7 @@
                                coords[1] - 5,
                                coords[0] + 5,
                                coords[1] + 5)
-                pdc.SetIdBounds(drawid, coordsBound)
+                pdc.SetIdBounds(drawid, wx.Rect(coordsBound))
                 # self.ovlcoords[drawid] = coords
 
         elif pdctype == 'text': # draw text on top of map
@@ -356,7 +365,7 @@
                 pdc.DrawText(img['text'], coords[0], coords[1])
             else:
                 pdc.DrawRotatedText(img['text'], coords[0], coords[1], rotation)
-            pdc.SetIdBounds(drawid, (coords[0], coords[1], w, h))
+            pdc.SetIdBounds(drawid, wx.Rect(coords[0], coords[1], w, h))
             
         pdc.EndDrawing()
         
@@ -462,8 +471,8 @@
                 # self.bufferLast = wx.BitmapFromImage(self.buffer.ConvertToImage())
                 self.bufferLast = dc.GetAsBitmap(wx.Rect(0, 0, self.Map.width, self.Map.height))
 
-            pdcLast = wx.PseudoDC()
-            pdcLast.DrawBitmap(bmp=self.bufferLast, x=0, y=0)
+            pdcLast = PseudoDC()
+            pdcLast.DrawBitmap(self.bufferLast, wx.Point(0, 0), False)
             pdcLast.DrawToDC(dc)
 
         # draw decorations (e.g. region box)
@@ -895,7 +904,6 @@
                 pass
             self.RefreshRect(r, False)
             pdc.SetId(self.lineid)
-
             self.Draw(pdc, drawid=self.lineid, pdctype='line', coords=mousecoords)
 
     def DrawLines(self, pdc=None, polycoords=None):
@@ -1380,7 +1388,7 @@
                 self.OnLeftDownVDigitCopyCA(event)
             
             elif digitToolbar.GetAction() == "copyLine":
-                self.OnLeftDownCopyLine(event)
+                self.OnLeftDownVDigitCopyLine(event)
             
             elif digitToolbar.GetAction() == "zbulkLine":
                 self.OnLeftDownVDigitBulkLine(event)
@@ -1580,6 +1588,9 @@
         digitToolbar = self.parent.toolbars['vdigit']
         digitClass   = self.parent.digit
         
+        pos1 = self.Pixel2Cell(self.mouse['begin'])
+        pos2 = self.Pixel2Cell(self.mouse['end'])
+        
         if UserSettings.Get(group='vdigit', key='bgmap',
                             subkey='value', internal=True) == '':
             # no background map -> copy from current vector map layer

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2009-02-08 14:43:28 UTC (rev 35802)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/vdigit.py	2009-02-08 14:49:46 UTC (rev 35803)
@@ -57,7 +57,7 @@
     digitErr = ''
 except ImportError, err:
     GV_LINES = None
-    PseudoDC = None
+    PseudoDC = wx.PseudoDC
     digitErr = err
     print >> sys.stderr, "%sWARNING: Digitization tool is disabled (%s). " \
           "Detailed information in README file." % \

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp	2009-02-08 14:43:28 UTC (rev 35802)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp	2009-02-08 14:49:46 UTC (rev 35803)
@@ -23,10 +23,10 @@
    \param driver display driver instance
    \param window parent window for message dialog
 */
-Digit::Digit(DisplayDriver *ddriver, void *window)
+Digit::Digit(DisplayDriver *ddriver, wxWindow *window)
 {
     display = ddriver;
-    display->parentWin = (wxWindow *) window;
+    display->parentWin = window;
 
     if (display->mapInfo) {
 	InitCats();

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h	2009-02-08 14:43:28 UTC (rev 35802)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h	2009-02-08 14:49:46 UTC (rev 35803)
@@ -44,7 +44,7 @@
     int RemoveActionFromChangeset(int, action_type, int);
 
 public:
-    Digit(DisplayDriver *, void *);
+    Digit(DisplayDriver *, wxWindow *);
     ~Digit();
 
     int InitCats();

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp	2009-02-08 14:43:28 UTC (rev 35802)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.cpp	2009-02-08 14:49:46 UTC (rev 35803)
@@ -30,14 +30,14 @@
    
    \return
 */
-DisplayDriver::DisplayDriver(void *device, void *deviceTmp)
+DisplayDriver::DisplayDriver(gwxPseudoDC *device, gwxPseudoDC *deviceTmp)
 {
     G_gisinit(""); /* GRASS functions */
 
     mapInfo = NULL;
 
-    dc = (gwxPseudoDC *) device;
-    dcTmp = (gwxPseudoDC *) deviceTmp;
+    dc = device;
+    dcTmp = deviceTmp;
 
     points = Vect_new_line_struct();
     pointsScreen = new wxList();

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h	2009-02-08 14:43:28 UTC (rev 35802)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/driver.h	2009-02-08 14:49:46 UTC (rev 35803)
@@ -175,7 +175,7 @@
     
 public:
     /* constructor */
-    DisplayDriver(void *, void *);
+    DisplayDriver(gwxPseudoDC *, gwxPseudoDC *);
     /* destructor */
     ~DisplayDriver();
 

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/pseudodc.i
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/pseudodc.i	2009-02-08 14:43:28 UTC (rev 35802)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/pseudodc.i	2009-02-08 14:49:46 UTC (rev 35803)
@@ -1,4 +1,3 @@
-
 %{
 #include <wx/wxPython/wxPython.h>
 #include <wx/wxPython/pyclasses.h>
@@ -20,8 +19,19 @@
 	gwxPseudoDC();
 	~gwxPseudoDC();
 	void Clear();
+    	void ClearId(int);
 	void RemoveAll();
-	void RemoveId(int id);
+	void RemoveId(int);
+	void BeginDrawing();
+	void EndDrawing();
+        void SetBackground(const wxBrush&);
+	void SetId(int);
+        void DrawBitmap(const wxBitmap&, const wxPoint&,
+	                bool);
+        void SetBrush(const wxBrush&);
+        void SetPen(const wxPen&);
+	void SetIdBounds(int, wxRect&);
+	void DrawLine(const wxPoint&, const wxPoint&);
 	%extend {
 		void DrawToDC(void *dc) {
 			self->DrawToDC((wxDC *) dc);
@@ -34,6 +44,8 @@
 			self->GetIdBounds(id, rect);
 			return rect;
 		}
+		void TranslateId(int id, int dx, int dy) {
+		        self->TranslateId(id, (wxCoord) dx, (wxCoord) dy);
+		}
 	}
 };
-



More information about the grass-commit mailing list