Changeset 8635:f5ed4f7ae261 in orange


Ignore:
Timestamp:
08/09/11 11:49:19 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
cb530c1bd156a4b93470fcf0e8ab4b54e24d4881
Message:

Move label drawing to Point

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Prototypes/OWScatterPlotGraphQt.py

    r8633 r8635  
    8787            sizeIndex = self.attributeNameIndex[sizeShapeAttr] 
    8888             
    89         labelIndex = -1 
    90         if labelAttr != "" and labelAttr != "(Same label)": 
    91             labelIndex = self.attributeNameIndex[labelAttr] 
    92  
    9389        showContinuousColorLegend = self.showLegend and colorIndex != -1 and self.dataDomain[colorIndex].varType == orange.VarTypes.Continuous 
    9490 
     
    187183                 
    188184            if labelAttr and labelAttr in [self.rawData.domain.getmeta(mykey).name for mykey in self.rawData.domain.getmetas().keys()] + [var.name for var in self.rawData.domain]: 
    189                 if self.dataDomain[0][labelAttr].varType == orange.VarTypes.Continuous: 
     185                if self.rawData[0][labelAttr].varType == orange.VarTypes.Continuous: 
    190186                    labelData = ["%4.1f" % orange.Value(i[labelAttr]) if not i[labelAttr].isSpecial() else "" for i in self.rawData] 
    191187                else: 
  • source/orangeplot/networkcurve.cpp

    r8634 r8635  
    3232void NodeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) 
    3333{ 
    34     Point::paint(painter, option, widget); 
    35  
    36     NetworkCurve *curve = (NetworkCurve*)parentItem(); 
    37     bool on_marked_only = curve->labels_on_marked_only(); 
    38  
    39     if (m_label.compare("") != 0 && (!on_marked_only || is_marked())) 
    40     { 
    41         QFontMetrics metrics = painter->fontMetrics(); 
    42         int th = metrics.height(); 
    43         int tw = metrics.width(m_label); 
    44         QRect r(-tw/2, 0, tw, th); 
    45         //painter->fillRect(r, QBrush(Qt::white)); 
    46         painter->drawText(r, Qt::AlignHCenter, m_label); 
    47     } 
     34    NetworkCurve *curve = (NetworkCurve*)parentItem(); 
     35    bool on_marked_only = curve->labels_on_marked_only(); 
     36    const QString l = label(); 
     37    if (on_marked_only && !is_marked() && l.isEmpty()) 
     38    { 
     39        set_label(QString()); 
     40    } 
     41    Point::paint(painter, option, widget); 
     42    set_label(l); 
    4843} 
    4944 
  • source/orangeplot/networkcurve.h

    r8634 r8635  
    110110     
    111111    int m_index; 
    112     QString m_label; 
    113112    int m_uuid; 
    114113     
  • source/orangeplot/point.cpp

    r8633 r8635  
    44#include <QtCore/QDebug> 
    55#include <QtCore/qmath.h> 
     6#include <QtGui/QStyleOptionGraphicsItem> 
    67 
    78QHash<PointData, QPixmap> Point::pixmap_cache; 
     
    9798    } 
    9899    painter->drawPixmap(QPointF(-0.5*ps, -0.5*ps), pixmap_cache.value(key)); 
     100    if (!m_label.isEmpty()) 
     101    {         
     102        QFontMetrics metrics = option->fontMetrics; 
     103        int th = metrics.height(); 
     104        int tw = metrics.width(m_label); 
     105        QRect r(-tw/2, 0, tw, th); 
     106        //painter->fillRect(r, QBrush(Qt::white)); 
     107        painter->drawText(r, Qt::AlignHCenter, m_label); 
     108    } 
     109 
    99110} 
    100111 
Note: See TracChangeset for help on using the changeset viewer.