Changeset 8692:5b4c1e01a902 in orange


Ignore:
Timestamp:
08/13/11 13:40:48 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
7402ff0754e451c85fe6a134bfa791f29299fd20
Message:

Threaded setting of coordinates to points.

Location:
source/orangeqt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • source/orangeqt/curve.cpp

    r8690 r8692  
    4444    m_needsUpdate = UpdateAll; 
    4545    set_data(x_data, y_data); 
    46     QObject::connect(&m_watcher, SIGNAL(finished()), SLOT(pointMapFinished())); 
    47      
     46    QObject::connect(&m_pos_watcher, SIGNAL(finished()), SLOT(pointMapFinished())); 
     47    QObject::connect(&m_coords_watcher, SIGNAL(finished()), SLOT(update_point_positions())); 
    4848    m_autoUpdate = true; 
    4949} 
     
    5555    m_lineItem = 0; 
    5656    m_needsUpdate = 0; 
    57     QObject::connect(&m_watcher, SIGNAL(finished()), SLOT(pointMapFinished())); 
     57    QObject::connect(&m_pos_watcher, SIGNAL(finished()), SLOT(pointMapFinished())); 
     58    QObject::connect(&m_coords_watcher, SIGNAL(finished()), SLOT(update_point_positions())); 
    5859} 
    5960 
     
    448449} 
    449450 
     451void Curve::update_point_coordinates() 
     452{ 
     453    if (m_coords_watcher.future().isRunning()) 
     454    { 
     455        m_coords_watcher.future().cancel(); 
     456        m_coords_watcher.future().waitForFinished(); 
     457    } 
     458    m_coords_watcher.setFuture(QtConcurrent::run(this, &Curve::update_point_properties_threaded<DataPoint>, QByteArray("coordinates"), m_data)); 
     459} 
     460 
    450461void Curve::update_point_positions() 
    451462{ 
    452     if (m_watcher.future().isRunning()) 
    453     { 
    454         m_watcher.future().cancel(); 
    455         m_watcher.future().waitForFinished(); 
     463    if (m_pos_watcher.future().isRunning()) 
     464    { 
     465        m_pos_watcher.future().cancel(); 
     466        m_pos_watcher.future().waitForFinished(); 
    456467    } 
    457468    if (plot() && plot()->animate_points) 
    458469    { 
    459         m_watcher.setFuture(QtConcurrent::mapped(m_pointItems, PointPosMapper(m_graphTransform))); 
     470        m_pos_watcher.setFuture(QtConcurrent::mapped(m_pointItems, PointPosMapper(m_graphTransform))); 
    460471    } 
    461472    else 
     
    467478void Curve::pointMapFinished() 
    468479{ 
    469     if (m_pointItems.size() != m_watcher.future().results().size()) 
     480    if (m_pointItems.size() != m_pos_watcher.future().results().size()) 
    470481    { 
    471482        // The calculation that just finished is already out of date, ignore it 
     
    477488    { 
    478489        QPropertyAnimation* a = new QPropertyAnimation(m_pointItems[i], "pos"); 
    479         a->setEndValue(m_watcher.resultAt(i)); 
     490        a->setEndValue(m_pos_watcher.resultAt(i)); 
    480491        group->addAnimation(a); 
    481492    } 
  • source/orangeqt/curve.h

    r8690 r8692  
    212212  template <class Sequence, class Updater> 
    213213  void update_items(const Sequence& sequence, Updater updater, Curve::UpdateFlag flag); 
    214    
    215   void update_point_positions(); 
    216    
     214     
    217215  template <class T> 
    218216  void update_point_properties(const QByteArray& property, const QList< T >& values, bool animate = true); 
     
    238236  bool use_animations(); 
    239237   
     238public slots: 
     239    void update_point_coordinates(); 
     240    void update_point_positions(); 
     241   
    240242private slots: 
    241243    void pointMapFinished(); 
    242    
     244 
    243245private: 
    244246  QColor m_color; 
     
    259261  QTransform m_zoom_transform; 
    260262  QMap<UpdateFlag, QFuture<void> > m_currentUpdate; 
    261   QFutureWatcher<QPointF> m_watcher; 
     263  QFutureWatcher<QPointF> m_pos_watcher; 
     264  QFutureWatcher<void> m_coords_watcher; 
    262265   
    263266}; 
     
    315318    for (int i = 0; i < n; ++i) 
    316319    { 
    317         m_pointItems[i]->setProperty(property, values[i]); 
     320        m_pointItems[i]->setProperty(property, QVariant::fromValue<T>(values[i])); 
    318321    } 
    319322} 
  • source/orangeqt/multicurve.cpp

    r8690 r8692  
    6565    const QList<Point*> p = points(); 
    6666     
    67     for (int i = 0; i < n; ++i) 
    68     { 
    69         p[i]->set_coordinates(d[i]); 
    70     } 
    71      
    72     register_points(); 
    73     update_point_positions(); 
     67    update_point_coordinates(); 
    7468    update_items(points(), ZoomUpdater(point_transform()), UpdateZoom); 
    7569} 
  • source/orangeqt/point.h

    r8690 r8692  
    3232  operator QPointF(); 
    3333}; 
     34 
     35Q_DECLARE_METATYPE(DataPoint) 
    3436 
    3537QDebug& operator<<(QDebug& stream, const DataPoint& point); 
     
    5355    Q_PROPERTY(int size READ size WRITE set_size) 
    5456    Q_PROPERTY(QString label READ label WRITE set_label) 
     57    Q_PROPERTY(DataPoint coordinates READ coordinates WRITE set_coordinates) 
    5558     
    5659     
Note: See TracChangeset for help on using the changeset viewer.