Changeset 8479:191f3c5591d5 in orange


Ignore:
Timestamp:
07/27/11 12:46:37 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
9e3bb7b299e4b26b8e6c73fbc9773872463baceb
Message:

Enable point selection from the interface

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWToolbars.py

    r8342 r8479  
    4545    NavigateButtons = 1, 9, 10, 0, 2 
    4646 
    47     def __init__(self, widget, parent, graph, autoSend = 0, buttons = (1, 4, 5, 0, 6, 7, 8), name = "Zoom / Select", exclusiveList = "__toolbars"): 
     47    def __init__(self, widget, parent, graph, autoSend = 0, buttons = (1, 3, 4, 5, 0, 6, 7, 8), name = "Zoom / Select", exclusiveList = "__toolbars"): 
    4848        if not hasattr(ZoomSelectToolbar, "builtinFunctions"): 
    4949            ZoomSelectToolbar.builtinFunctions = \ 
     
    125125    IconSpace, IconZoom, IconPan, IconSelect, IconRectangle, IconPolygon, IconRemoveLast, IconRemoveAll, IconSendSelection, IconZoomExtent, IconZoomSelection = range(11) 
    126126 
    127     def __init__(self, widget, parent, graph, autoSend = 0, buttons = (1, 4, 5, 0, 6, 7, 8)): 
     127    def __init__(self, widget, parent, graph, autoSend = 0, buttons = (1, 3, 4, 5, 0, 6, 7, 8)): 
    128128        if not hasattr(NavigateSelectToolbar, "builtinFunctions"): 
    129129            NavigateSelectToolbar.builtinFunctions = (None, 
  • orange/OrangeWidgets/plot/owplot.py

    r8476 r8479  
    8686    "updateLayout" : "update_layout",  
    8787    "activateZooming" : "activate_zooming",  
     88    "activateSelection" : "activate_selection",  
    8889    "activateRectangleSelection" : "activate_rectangle_selection",  
    8990    "activatePolygonSelection" : "activate_polygon_selection",  
     
    251252    def activate_rectangle_selection(self): 
    252253        self.state = SELECT_RECTANGLE 
     254         
     255    def activate_selection(self): 
     256        self.state = SELECT 
    253257         
    254258    def activate_polygon_selection(self): 
     
    744748                    break 
    745749            self.selection_items.reverse() 
     750        elif self.state == SELECT: 
     751            point_item = self.point_at(point) 
     752            qDebug(repr(point) + ' ' + repr(point_item)) 
     753            if point_item: 
     754                point_item.set_selected(True) 
    746755        else: 
    747756            return False 
  • source/orangeplot/plot.cpp

    r8476 r8479  
    187187} 
    188188 
     189Point* Plot::point_at(const QPointF& pos) 
     190{ 
     191    Point* point; 
     192    foreach (QGraphicsItem* item, scene()->items(pos)) 
     193    { 
     194        if (point = qgraphicsitem_cast<Point*>(item)) 
     195        { 
     196            return point; 
     197        } 
     198    } 
     199    return 0; 
     200} 
    189201 
    190202#include "plot.moc" 
  • source/orangeplot/plot.h

    r8476 r8479  
    4444    QList< int > selected_points(const QList< double > x_data, const QList< double > y_data, const QTransform& transform); 
    4545     
     46    Point* point_at(const QPointF& pos); 
     47     
    4648protected: 
    4749    void set_clean();; 
  • source/orangeplot/plot.sip

    r8476 r8479  
    6363     
    6464    QList< int > selected_points(const QList< double > x_data, const QList< double > y_data, const QTransform& transform); 
     65    Point* point_at(const QPointF& pos); 
    6566     
    6667protected: 
  • source/orangeplot/point.h

    r8475 r8479  
    4646    }; 
    4747     
     48    Q_DECLARE_FLAGS(State, StateFlag) 
     49   
    4850    enum  
    4951    { 
     
    5658    } 
    5759     
    58     Q_DECLARE_FLAGS(State, StateFlag) 
    59    
    6060    Point(QGraphicsItem* parent = 0, QGraphicsScene* scene = 0); 
    6161    Point(int symbol, QColor color, int size, QGraphicsItem* parent = 0); 
  • source/orangeplot/point.sip

    r8444 r8479  
    3232    UserStyle = 1000 
    3333  }; 
     34 
     35    enum StateFlag 
     36    { 
     37        Normal = 0x00, 
     38        Marked = 0x01, 
     39        Selected = 0x02 
     40    }; 
     41 
     42    typedef QFlags<Point::StateFlag> State; 
    3443   
    3544    Point(QGraphicsItem* parent /TransferThis/ = 0, QGraphicsScene* scene /TransferThis/ = 0); 
     
    5261    DisplayMode display_mode() const; 
    5362 
     63    void set_state(State state); 
     64    State state() const; 
     65    void set_state_flag(StateFlag flag, bool on); 
     66    bool state_flag(StateFlag flag) const; 
     67     
     68    void set_selected(bool selected); 
     69    bool is_selected() const; 
     70 
     71    void set_marked(bool marked); 
     72    bool is_marked() const; 
     73 
     74 
    5475    /** 
    5576    * Creates a path from a symbol and a size 
Note: See TracChangeset for help on using the changeset viewer.