Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added button for Autoboundary and functionality for that and autoboun…

…dary on menu. Fixed some label positioning issues with boundary.
  • Loading branch information...
commit 73a8fa48ac3d7fbbe96a0280c956ab83b1846212 1 parent 50e78b8
@Ooorah authored
View
17 src/RegionEditorFiles/NewRegionEditor/RegionEditorV3.wxg
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!-- generated by wxGlade 0.6.5 (standalone edition) on Wed Apr 18 09:36:00 2012 -->
+<!-- generated by wxGlade 0.6.5 (standalone edition) on Wed Apr 18 14:54:39 2012 -->
<application path="C:\Users\cws68\ltlmop\src\RegionEditorFiles\NewRegionEditor\regionEditor.py" name="" class="" option="0" language="python" top_window="regEd" encoding="ISO-8859-15" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
<object class="regionEditor" name="regEd" base="EditFrame">
@@ -120,7 +120,7 @@
<option>0</option>
<object class="wxPanel" name="sidebar" base="EditPanel">
<style>wxTAB_TRAVERSAL</style>
- <size>150, 400</size>
+ <size>120, 400</size>
<object class="wxGridSizer" name="grid_sizer_1" base="EditGridSizer">
<hgap>5</hgap>
<rows>4</rows>
@@ -186,7 +186,18 @@
<size>50, 50</size>
</object>
</object>
- <object class="sizerslot" />
+ <object class="sizeritem">
+ <flag>wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
+ <border>0</border>
+ <option>0</option>
+ <object class="wxButton" name="buttonAutobound" base="EditButton">
+ <label>Boundary</label>
+ <events>
+ <handler event="EVT_BUTTON">OnButtonAutobound</handler>
+ </events>
+ <size>50, 50</size>
+ </object>
+ </object>
<object class="sizeritem">
<flag>wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag>
<border>0</border>
View
63 src/regionEditor.py
@@ -85,6 +85,7 @@ def __init__(self, *args, **kwds):
self.toggleSquare = wx.ToggleButton(self.sidebar, -1, "Rect.")
self.togglePoly = wx.ToggleButton(self.sidebar, -1, "Polygon")
self.toggleDim = wx.ToggleButton(self.sidebar, -1, "Length")
+ self.buttonAutobound = wx.Button(self.sidebar, -1, "Boundary")
self.toggleFeedback = wx.ToggleButton(self.sidebar, -1, "Feedback")
self.buttonCal = wx.Button(self.sidebar, -1, "Calibrate")
self.canvas = wx.Panel(self, -1, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL)
@@ -115,6 +116,7 @@ def __init__(self, *args, **kwds):
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggleSquare, self.toggleSquare)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnTogglePoly, self.togglePoly)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggleDim, self.toggleDim)
+ self.Bind(wx.EVT_BUTTON, self.OnButtonAutobound, self.buttonAutobound)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggleFeedback, self.toggleFeedback)
self.Bind(wx.EVT_BUTTON, self.OnButtonCal, self.buttonCal)
# end wxGlade
@@ -212,9 +214,10 @@ def __set_properties(self):
self.toggleSquare.SetMinSize((50, 50))
self.togglePoly.SetMinSize((50, 50))
self.toggleDim.SetMinSize((50, 50))
+ self.buttonAutobound.SetMinSize((50, 50))
self.toggleFeedback.SetMinSize((50, 50))
self.buttonCal.SetMinSize((50, 50))
- self.sidebar.SetMinSize((150, 400))
+ self.sidebar.SetMinSize((120, 400))
self.canvas.SetMinSize((800, 400))
self.canvas.SetBackgroundColour(wx.Colour(255, 255, 255))
# end wxGlade
@@ -228,6 +231,7 @@ def __do_layout(self):
grid_sizer_1.Add(self.toggleSquare, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
grid_sizer_1.Add(self.togglePoly, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
grid_sizer_1.Add(self.toggleDim, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
+ grid_sizer_1.Add(self.buttonAutobound, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
grid_sizer_1.Add(self.toggleFeedback, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
grid_sizer_1.Add(self.buttonCal, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
self.sidebar.SetSizer(grid_sizer_1)
@@ -256,7 +260,7 @@ def OnClose(self, event):
else:
self.viconListener.stop()
self.Destroy()
-
+
def OnToggleVicon(self, event): # wxGlade: regionEditor.<event_handler>
# Switch Vicon streaming on or off based on state of toggle button
if self.toggleVicon.GetValue():
@@ -269,21 +273,25 @@ def OnToggleVicon(self, event): # wxGlade: regionEditor.<event_handler>
self.viconListener.stop()
# Reinitialize thread to enable restarting it
self.viconListener = ViconMarkerListener(self)
-
+
def OnButtonCamera(self, event): # wxGlade: regionEditor.<event_handler>
print "Camera not yet implemented"
# TODO
event.Skip()
-
+
def OnToggleSquare(self, event): # wxGlade: regionEditor.<event_handler>
self.ResetMapToggles(self.toggleSquare)
-
+
def OnTogglePoly(self, event): # wxGlade: regionEditor.<event_handler>
self.ResetMapToggles(self.togglePoly)
-
+
def OnToggleDim(self, event): # wxGlade: regionEditor.<event_handler>
self.ResetMapToggles(self.toggleDim)
-
+
+ def OnButtonAutobound(self, event): # wxGlade: regionEditor.<event_handler>
+ self.Autoboundary()
+ self.RedrawCanvas()
+
def OnToggleFeedback(self, event): # wxGlade: regionEditor.<event_handler>
self.ResetMapToggles(self.toggleFeedback)
if self.toggleFeedback.GetValue():
@@ -291,7 +299,7 @@ def OnToggleFeedback(self, event): # wxGlade: regionEditor.<event_handler>
self.dlgFeedback.ShowModal()
elif self.dlgFeedback:
self.dlgFeedback.OnClose(None)
-
+
def OnButtonCal(self, event): # wxGlade: regionEditor.<event_handler>
self.ResetMapToggles()
calibGUI = CalibrationFrame(self)
@@ -385,6 +393,18 @@ def OnMenuOpen(self, event): # wxGlade: regionEditor.<event_handler>
def OnMenuSave(self, event): # wxGlade: regionEditor.<event_handler>
"""Save to file that has already been used."""
if self.fileName:
+ # Bring up dialog box to ask about boundary if necessary
+ if self.regions and not self.boundary:
+ msg = "No boundary found. Automatically create rectangular boundary?"
+ boundDialog = wx.MessageDialog(self, msg, style=wx.YES_NO|wx.CANCEL|\
+ wx.YES_DEFAULT|wx.ICON_EXCLAMATION|wx.STAY_ON_TOP)
+ boundDiaResult = boundDialog.ShowModal()
+ if boundDiaResult == wx.ID_YES:
+ self.Autoboundary()
+ elif boundDiaResult == wx.ID_CANCEL:
+ return
+
+ # Save file
f = open(self.fileName, 'w')
f.write("# This is a region definition file for the LTLMoP " + \
"toolkit.\n# Format details are described at the " + \
@@ -396,9 +416,7 @@ def OnMenuSave(self, event): # wxGlade: regionEditor.<event_handler>
f.write("\n\n") # TODO: Support for obstacles
f.write("Regions: # Name {ColorR ColorG ColorB} " + \
"[(x1 y1) (x2 y2) ...]\n")
- if not self.boundary:
- self.Autoboundary()
- if self.boundary: # Check in case there were no regions
+ if self.boundary:
f.write(str(self.boundary) + "\n")
for reg in self.regions:
f.write(str(reg) + "\n")
@@ -518,8 +536,8 @@ def OnMenuRedo(self, event): # wxGlade: regionEditor.<event_handler>
self.RedrawCanvas()
def OnMenuAutobound(self, event): # wxGlade: regionEditor.<event_handler>
- print "Event handler `OnMenuAutobound' not implemented"
- event.Skip()
+ self.Autoboundary()
+ self.RedrawCanvas()
def OnMenuRect(self, event): # wxGlade: regionEditor.<event_handler>
print "Event handler `OnMenuRect' not implemented"
@@ -891,7 +909,7 @@ def RedrawCanvas(self, dc=None):
# Redraw boundary region
if self.boundary:
- self.DrawRegion(self.boundary, dc, boundary=True)
+ self.DrawRegion(self.boundary, dc, isBoundary=True)
# Redraw all regions
for region in self.regions:
@@ -1022,15 +1040,17 @@ def DrawRegion(self, region, dc=None, isBoundary=False):
# Set brush to region color
if isBoundary:
dc.SetBrush(wx.Brush(region.color, wx.TRANSPARENT))
+ dc.SetPen(wx.Pen(wx.BLACK, 3, wx.SOLID))
elif region.isObstacle:
obstColor = wx.Colour(region.color.Red() / 10, \
region.color.Green() / 10, region.color.Blue() / 10, 128)
dc.SetBrush(wx.Brush(obstColor, wx.SOLID))
+ dc.SetPen(wx.Pen(region.color, 1, wx.SOLID))
else:
innerColor = wx.Colour(region.color.Red(), region.color.Green(), \
region.color.Blue(), 128)
dc.SetBrush(wx.Brush(innerColor, wx.SOLID))
- dc.SetPen(wx.Pen(region.color, 1, wx.SOLID))
+ dc.SetPen(wx.Pen(region.color, 1, wx.SOLID))
dc.SetTextForeground(wx.BLACK)
dc.SetBackgroundMode(wx.TRANSPARENT)
dc.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.BOLD, False))
@@ -1057,16 +1077,17 @@ def DrawRegion(self, region, dc=None, isBoundary=False):
yLabelPix = max(yLabelPix, vertPix[1])
dc.DrawPolygon(vertsPix)
if isBoundary:
- xLabelPix = xLabelPix / len(region.verts) - labelWidth
- yLabelPix = yLabelPix / len(region.verts) - labelHeight
+ xLabelPix = xLabelPix - labelWidth
+ yLabelPix = yLabelPix
else:
xLabelPix = xLabelPix / len(region.verts) - labelWidth / 2
yLabelPix = yLabelPix / len(region.verts) - labelHeight / 2
# Draw label
- dc.SetBrush(wx.Brush(region.color, wx.SOLID))
- dc.DrawRoundedRectangle(xLabelPix - 5, yLabelPix - 3, \
- labelWidth + 10, labelHeight + 6, 3)
+ if not isBoundary:
+ dc.SetBrush(wx.Brush(region.color, wx.SOLID))
+ dc.DrawRoundedRectangle(xLabelPix - 5, yLabelPix - 3, \
+ labelWidth + 10, labelHeight + 6, 3)
dc.DrawText(labelText, xLabelPix, yLabelPix)
if isNewDC:
@@ -2224,6 +2245,7 @@ def OnMapMouseWheel(self, event):
def OnMapEnterWindow(self, event):
"""Set focus on map to enable zooming."""
self.map.SetFocus()
+ self.RedrawMap()
def OnMapLeaveWindow(self, event):
"""Return focus to main GUI."""
@@ -2284,6 +2306,7 @@ def OnRefMouseWheel(self, event):
def OnRefEnterWindow(self, event):
"""Set focus on reference panel to enable zooming."""
self.ref.SetFocus()
+ self.RedrawRef()
def OnRefLeaveWindow(self, event):
"""Return focus to main GUI."""
Please sign in to comment.
Something went wrong with that request. Please try again.