示例#1
0
    def OnSlideColour(self, event):

        col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(),
                         self._bslider1.GetValue())
        col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(),
                         self._bslider2.GetValue())

        style = fpb.CaptionBarStyle()

        counter = 0
        for items in self.radiocontrols:
            if items.GetValue():
                break

            counter = counter + 1

        if counter == 0:
            mystyle = fpb.CAPTIONBAR_GRADIENT_V
        elif counter == 1:
            mystyle = fpb.CAPTIONBAR_GRADIENT_H
        elif counter == 2:
            mystyle = fpb.CAPTIONBAR_SINGLE
        elif counter == 3:
            mystyle = fpb.CAPTIONBAR_RECTANGLE
        else:
            mystyle = fpb.CAPTIONBAR_FILLED_RECTANGLE

        style.SetFirstColour(col1)
        style.SetSecondColour(col2)
        style.SetCaptionStyle(mystyle)

        item = self._pnl.GetFoldPanel(0)
        self._pnl.ApplyCaptionStyle(item, style)
示例#2
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
        self.SetBackgroundColour(default_colour)

        # Fold panel and its style settings
        # FIXME: If we dont insert a value in size or if we set wx.DefaultSize,
        # the fold_panel doesnt show. This means that, for some reason, Sizer
        # is not working properly in this panel. It might be on some child or
        # parent panel. Perhaps we need to insert the item into the sizer also...
        # Study this.
        fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition,
                                      wx.DefaultSize, 0, fpb.FPB_SINGLE_FOLD)

        # Fold panel style
        style = fpb.CaptionBarStyle()
        style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V)
        style.SetFirstColour(default_colour)
        style.SetSecondColour(default_colour)

        # Fold 1 - Surface properties
        item = fold_panel.AddFoldPanel(_("Surface properties"), collapsed=True)
        fold_panel.ApplyCaptionStyle(item, style)
        fold_panel.AddFoldPanelWindow(item,
                                      SurfaceProperties(item),
                                      spacing=0,
                                      leftSpacing=0,
                                      rightSpacing=0)

        # Fold 2 - Surface tools
        item = fold_panel.AddFoldPanel(_("Advanced options"), collapsed=True)
        fold_panel.ApplyCaptionStyle(item, style)
        fold_panel.AddFoldPanelWindow(item,
                                      SurfaceTools(item),
                                      spacing=0,
                                      leftSpacing=0,
                                      rightSpacing=0)

        #fold_panel.AddFoldPanelWindow(item, QualityAdjustment(item), Spacing= 0,
        #                              leftSpacing=0, rightSpacing=0)
        #fold_panel.Expand(fold_panel.GetFoldPanel(1))

        self.fold_panel = fold_panel
        self.__bind_evt()

        # Panel sizer to expand fold panel
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(fold_panel, 1, wx.GROW | wx.EXPAND)
        sizer.Fit(self)

        self.SetSizer(sizer)
        self.Update()
        self.SetAutoLayout(1)

        fold_panel.Expand(fold_panel.GetFoldPanel(1))
        self.ResizeFPB()
        fold_panel.Expand(fold_panel.GetFoldPanel(0))
示例#3
0
    def OnStyleChange(self, event):

        style = fpb.CaptionBarStyle()

        eventid = event.GetId()

        if eventid == self.ID_USE_HGRADIENT:
            style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_H)

        elif eventid == self.ID_USE_VGRADIENT:
            style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V)

        elif eventid == self.ID_USE_SINGLE:
            style.SetCaptionStyle(fpb.CAPTIONBAR_SINGLE)

        elif eventid == self.ID_USE_RECTANGLE:
            style.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE)

        elif eventid == self.ID_USE_FILLED_RECTANGLE:
            style.SetCaptionStyle(fpb.CAPTIONBAR_FILLED_RECTANGLE)

        else:
            raise "ERROR: Undefined Style Selected For CaptionBar: " + repr(
                eventid)

        col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(),
                         self._bslider1.GetValue())
        col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(),
                         self._bslider2.GetValue())

        style.SetFirstColour(col1)
        style.SetSecondColour(col2)

        if self._single.GetValue():
            item = self._pnl.GetFoldPanel(1)
            self._pnl.ApplyCaptionStyle(item, style)
        else:
            self._pnl.ApplyCaptionStyleAll(style)
示例#4
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
        self.SetBackgroundColour(default_colour)

        # Fold panel and its style settings
        # FIXME: If we dont insert a value in size or if we set wx.DefaultSize,
        # the fold_panel doesnt show. This means that, for some reason, Sizer
        # is not working properly in this panel. It might be on some child or
        # parent panel. Perhaps we need to insert the item into the sizer also...
        # Study this.
        #gbs = wx.GridBagSizer()

        #gbs.AddGrowableRow(0, 1)
        #gbs.AddGrowableCol(0, 1)

        #self.gbs = gbs

        self.last_size = None

        # Panel sizer to expand fold panel
        sizer = wx.BoxSizer(wx.VERTICAL)
        #sizer.Add(gbs, 1, wx.GROW|wx.EXPAND)
        self.SetSizer(sizer)

        fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition,
                                      wx.DefaultSize, 0, fpb.FPB_SINGLE_FOLD)
        self.fold_panel = fold_panel

        # Fold panel style
        style = fpb.CaptionBarStyle()
        style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V)
        style.SetFirstColour(default_colour)
        style.SetSecondColour(default_colour)

        # Fold 1 - Mask properties
        item = fold_panel.AddFoldPanel(_("Mask properties"), collapsed=True)
        self.mask_prop_panel = MaskProperties(item)

        fold_panel.ApplyCaptionStyle(item, style)
        fold_panel.AddFoldPanelWindow(item,
                                      self.mask_prop_panel,
                                      spacing=0,
                                      leftSpacing=0,
                                      rightSpacing=0)

        # Fold 2 - Advanced edition tools
        item = fold_panel.AddFoldPanel(_("Manual edition"), collapsed=True)
        etw = EditionTools(item)

        fold_panel.ApplyCaptionStyle(item, style)
        fold_panel.AddFoldPanelWindow(item,
                                      etw,
                                      spacing=0,
                                      leftSpacing=0,
                                      rightSpacing=0)
        self.__id_editor = item.GetId()
        self.last_panel_opened = None

        # Fold 3 - Watershed
        item = fold_panel.AddFoldPanel(_("Watershed"), collapsed=True)
        wtw = WatershedTool(item)

        fold_panel.ApplyCaptionStyle(item, style)
        fold_panel.AddFoldPanelWindow(item,
                                      wtw,
                                      spacing=0,
                                      leftSpacing=0,
                                      rightSpacing=0)
        self.__id_watershed = item.GetId()

        sizer.Add(fold_panel, 1, wx.EXPAND)

        fold_panel.Expand(fold_panel.GetFoldPanel(2))
        self.ResizeFPB()
        fold_panel.Expand(fold_panel.GetFoldPanel(0))

        sizer.Layout()
        self.Fit()

        self.fold_panel = fold_panel
        self.last_style = None

        self.__bind_evt()
        self.__bind_pubsub_evt()
示例#5
0
    def ReCreateFoldPanel(self, fpb_flags):

        # delete earlier panel
        self._leftWindow1.DestroyChildren()

        # recreate the foldpanelbar

        self._pnl = fpb.FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition,
                                     wx.Size(-1, -1), fpb.FPB_DEFAULT_STYLE,
                                     fpb_flags)

        Images = wx.ImageList(16, 16)
        Images.Add(GetExpandedIconBitmap())
        Images.Add(GetCollapsedIconBitmap())

        item = self._pnl.AddFoldPanel("Caption Colours",
                                      collapsed=False,
                                      foldIcons=Images)

        self._pnl.AddFoldPanelWindow(
            item, wx.StaticText(item, -1, "Adjust The First Colour"),
            fpb.FPB_ALIGN_WIDTH, 5, 20)

        # RED color spin control
        self._rslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._rslider1, fpb.FPB_ALIGN_WIDTH,
                                     2, 20)

        # GREEN color spin control
        self._gslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._gslider1, fpb.FPB_ALIGN_WIDTH,
                                     0, 20)

        # BLUE color spin control
        self._bslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._bslider1, fpb.FPB_ALIGN_WIDTH,
                                     0, 20)

        self._pnl.AddFoldPanelSeparator(item)

        self._pnl.AddFoldPanelWindow(
            item, wx.StaticText(item, -1, "Adjust The Second Colour"),
            fpb.FPB_ALIGN_WIDTH, 5, 20)

        # RED color spin control
        self._rslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._rslider2, fpb.FPB_ALIGN_WIDTH,
                                     2, 20)

        # GREEN color spin control
        self._gslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._gslider2, fpb.FPB_ALIGN_WIDTH,
                                     0, 20)

        # BLUE color spin control
        self._bslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._bslider2, fpb.FPB_ALIGN_WIDTH,
                                     0, 20)

        self._pnl.AddFoldPanelSeparator(item)

        button1 = wx.Button(item, wx.ID_ANY, "Apply To All")
        button1.Bind(wx.EVT_BUTTON, self.OnExpandMe)
        self._pnl.AddFoldPanelWindow(item, button1)

        # read back current gradients and set the sliders
        # for the colour which is now taken as default

        style = self._pnl.GetCaptionStyle(item)
        col = style.GetFirstColour()

        self._rslider1.SetValue(col.Red())
        self._gslider1.SetValue(col.Green())
        self._bslider1.SetValue(col.Blue())

        col = style.GetSecondColour()
        self._rslider2.SetValue(col.Red())
        self._gslider2.SetValue(col.Green())
        self._bslider2.SetValue(col.Blue())

        # put down some caption styles from which the user can
        # select to show how the current or all caption bars will look like

        item = self._pnl.AddFoldPanel("Caption Style", False, foldIcons=Images)

        self.ID_USE_VGRADIENT = wx.NewId()
        self.ID_USE_HGRADIENT = wx.NewId()
        self.ID_USE_SINGLE = wx.NewId()
        self.ID_USE_RECTANGLE = wx.NewId()
        self.ID_USE_FILLED_RECTANGLE = wx.NewId()

        currStyle = wx.RadioButton(item, self.ID_USE_VGRADIENT,
                                   "&Vertical Gradient")
        self._pnl.AddFoldPanelWindow(item, currStyle, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)

        currStyle.SetValue(True)

        radio1 = wx.RadioButton(item, self.ID_USE_HGRADIENT,
                                "&Horizontal Gradient")
        radio2 = wx.RadioButton(item, self.ID_USE_SINGLE, "&Single Colour")
        radio3 = wx.RadioButton(item, self.ID_USE_RECTANGLE, "&Rectangle Box")
        radio4 = wx.RadioButton(item, self.ID_USE_FILLED_RECTANGLE,
                                "&Filled Rectangle Box")

        currStyle.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio1.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio2.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio3.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio4.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)

        self._pnl.AddFoldPanelWindow(item, radio1, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)
        self._pnl.AddFoldPanelWindow(item, radio2, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)
        self._pnl.AddFoldPanelWindow(item, radio3, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)
        self._pnl.AddFoldPanelWindow(item, radio4, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)

        self._pnl.AddFoldPanelSeparator(item)

        self._single = wx.CheckBox(item, -1, "&Only This Caption")
        self._pnl.AddFoldPanelWindow(item, self._single, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)

        # one more panel to finish it

        cs = fpb.CaptionBarStyle()
        cs.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE)

        item = self._pnl.AddFoldPanel("Misc Stuff",
                                      collapsed=True,
                                      foldIcons=Images,
                                      cbstyle=cs)

        button2 = wx.Button(item, wx.NewId(), "Collapse All")
        self._pnl.AddFoldPanelWindow(item, button2)
        self._pnl.AddFoldPanelWindow(
            item, wx.StaticText(item, -1, "Enter Some Comments"),
            fpb.FPB_ALIGN_WIDTH, 5, 20)
        self._pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, -1, "Comments"),
                                     fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)

        button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe)
        self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4]

        self._leftWindow1.SizeWindows()
示例#6
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
        self.SetBackgroundColour(default_colour)

        self.__bind_events()
        # Fold panel and its style settings
        # FIXME: If we dont insert a value in size or if we set wx.DefaultSize,
        # the fold_panel doesnt show. This means that, for some reason, Sizer
        # is not working properly in this panel. It might be on some child or
        # parent panel. Perhaps we need to insert the item into the sizer also...
        # Study this.
        displaySize = wx.DisplaySize()
        if displaySize[1] > 768:
            fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition,
                                          (10, 350), 0, fpb.FPB_SINGLE_FOLD)
        else:
            fold_panel = fpb.FoldPanelBar(self, -1, wx.DefaultPosition,
                                          (10, 293), 0, fpb.FPB_SINGLE_FOLD)
        # Fold panel style
        style = fpb.CaptionBarStyle()
        style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V)
        style.SetFirstColour(default_colour)
        style.SetSecondColour(default_colour)

        # Fold 1 - Navigation panel
        item = fold_panel.AddFoldPanel(_("Neuronavigation"), collapsed=True)
        ntw = NeuronavigationPanel(item)

        fold_panel.ApplyCaptionStyle(item, style)
        fold_panel.AddFoldPanelWindow(item,
                                      ntw,
                                      spacing=0,
                                      leftSpacing=0,
                                      rightSpacing=0)
        fold_panel.Expand(fold_panel.GetFoldPanel(0))

        # Fold 2 - Markers panel
        item = fold_panel.AddFoldPanel(_("Extra tools"), collapsed=True)
        mtw = MarkersPanel(item)

        fold_panel.ApplyCaptionStyle(item, style)
        fold_panel.AddFoldPanelWindow(item,
                                      mtw,
                                      spacing=0,
                                      leftSpacing=0,
                                      rightSpacing=0)

        # Check box for camera update in volume rendering during navigation
        tooltip = wx.ToolTip(_("Update camera in volume"))
        checkcamera = wx.CheckBox(self, -1, _('Volume camera'))
        checkcamera.SetToolTip(tooltip)
        checkcamera.SetValue(True)
        checkcamera.Bind(wx.EVT_CHECKBOX,
                         partial(self.UpdateVolumeCamera, ctrl=checkcamera))

        # Check box for camera update in volume rendering during navigation
        tooltip = wx.ToolTip(_("Enable external trigger for creating markers"))
        checktrigger = wx.CheckBox(self, -1, _('External trigger'))
        checktrigger.SetToolTip(tooltip)
        checktrigger.SetValue(False)
        checktrigger.Bind(
            wx.EVT_CHECKBOX,
            partial(self.UpdateExternalTrigger, ctrl=checktrigger))
        self.checktrigger = checktrigger

        if sys.platform != 'win32':
            checkcamera.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
            checktrigger.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        line_sizer = wx.BoxSizer(wx.HORIZONTAL)
        line_sizer.Add(checkcamera, 0, wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, 5)
        line_sizer.Add(checktrigger, 1, wx.ALIGN_RIGHT | wx.RIGHT | wx.LEFT, 5)
        line_sizer.Fit(self)

        # Panel sizer to expand fold panel
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(fold_panel, 0, wx.GROW | wx.EXPAND)
        sizer.Add(line_sizer, 1, wx.GROW | wx.EXPAND)
        sizer.Fit(self)

        self.SetSizer(sizer)
        self.Update()
        self.SetAutoLayout(1)
示例#7
0
    def __init__(self,
                 parent,
                 properties=None,
                 attProperties=None,
                 *args,
                 **kwargs):
        self._baseClass = dSlidePanel
        preClass = fpb.FoldPanelItem
        self._widthAlreadySet = self._heightAlreadySet = True
        self._border = 5

        # This needs to be set *after* the panel is added to its parent
        collapsed = self._extractKey(attProperties, "Collapsed", None)
        if collapsed is not None:
            collapsed = (collapsed == "True")
        else:
            collapsed = self._extractKey((kwargs, properties), "Collapsed",
                                         None)
            if collapsed is None:
                # They might have passed it as 'Expanded'
                collapsed = not self._extractKey(
                    (kwargs, properties), "Expanded", True)

        cbstyle = self._extractKey((kwargs, properties), "cbstyle", None)
        if cbstyle is None:
            kwargs["cbstyle"] = fpb.CaptionBarStyle()

        if isinstance(parent, fpb.FoldPanelBar):
            # Items have to be added to the internal panel instead
            self._cont = parent
            parent = parent._foldPanel
        else:
            # Must have been created from the parent control
            self._cont = parent.GetParent()

        self._captionForeColor = "black"
        self._barStyles = ("Borderless", "BorderOnly", "FilledBorder",
                           "VerticalFill", "HorizontalFill")
        self._barStylesLow = ("borderless", "borderonly", "filledborder",
                              "verticalfill", "horizontalfill")
        self._barStyleConstants = {
            "nostyle": fpb.CAPTIONBAR_NOSTYLE,
            "verticalfill": fpb.CAPTIONBAR_GRADIENT_V,
            "horizontalfill": fpb.CAPTIONBAR_GRADIENT_H,
            "borderless": fpb.CAPTIONBAR_SINGLE,
            "borderonly": fpb.CAPTIONBAR_RECTANGLE,
            "filledborder": fpb.CAPTIONBAR_FILLED_RECTANGLE
        }

        dcm.dControlMixin.__init__(self,
                                   preClass,
                                   parent,
                                   properties=properties,
                                   attProperties=attProperties,
                                   *args,
                                   **kwargs)

        self._cont.appendPanel(self)
        self._cont.RedisplayFoldPanelItems()
        if collapsed is not None:
            self.Collapsed = collapsed
        # Enable detection of clicks on the caption bar
        self._captionBar.Bind(wx.EVT_LEFT_UP, self.__onWxCaptionClick)
        # 		print "CAP BAR BINDING"
        # Set up the sizer
        self._baseSizer = sz = dabo.ui.dSizer("v")
        self.SetSizer(sz, True)
        sz.appendSpacer(self.CaptionHeight)