Changeset 8700:3c54aefcbcdf in orange


Ignore:
Timestamp:
08/14/11 14:14:37 (3 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
8013e918026f1f31e2d9fd02526b54fca310ea73
Message:

Fixed a bug in label on marked only. Show edge weight.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Visualize Qt/OWNxCanvasQt.py

    r8698 r8700  
    329329        weights = [[] for ex in edges] 
    330330        if self.show_weights: 
    331             weights = [[str(self.graph[u][v])] for u,v in edges] 
     331            weights = [["%.2f" % self.graph[u][v].get('weight', 1)] for u,v in edges] 
    332332             
    333333        self.networkCurve.set_edge_labels([', '.join(weights[i] + \ 
  • orange/OrangeWidgets/Visualize Qt/OWNxExplorerQt.py

    r8698 r8700  
    13611361        self.set_edge_colors() 
    13621362             
    1363         self.networkCanvas.setEdgesSize() 
    13641363        self.clickedAttLstBox() 
    13651364        self.clickedTooltipLstBox() 
  • source/orangeqt/networkcurve.cpp

    r8697 r8700  
    5656    bool on_marked_only = curve->labels_on_marked_only(); 
    5757    const QString l = label(); 
    58     if (on_marked_only && !is_marked() && l.isEmpty()) 
     58 
     59    if (on_marked_only && !(is_marked() || is_selected())) 
    5960    { 
    6061        set_label(QString()); 
    6162    } 
     63 
    6264    Point::paint(painter, option, widget); 
    6365    set_label(l); 
     
    204206    painter->setRenderHint(QPainter::Antialiasing, false); 
    205207    QGraphicsLineItem::paint(painter, option, widget); 
     208 
     209    if (!m_label.isEmpty()) 
     210    { 
     211        NetworkCurve *curve = (NetworkCurve*)parentItem(); 
     212        bool on_marked_only = curve->labels_on_marked_only(); 
     213        bool is_marked = (u()->is_marked() || u()->is_selected()) && (v()->is_marked() || v()->is_selected()); 
     214 
     215        if(!on_marked_only || (on_marked_only && is_marked)) 
     216        { 
     217            QLineF _line = line(); 
     218            double x = (_line.x1() + _line.x2()) / 2; 
     219            double y = (_line.y1() + _line.y2()) / 2; 
     220            QFontMetrics metrics = option->fontMetrics; 
     221            int th = metrics.height(); 
     222            int tw = metrics.width(m_label); 
     223            QRect r(x-tw/2, y-th/2, tw, th); 
     224            //painter->fillRect(r, QBrush(Qt::white)); 
     225            QPen p = painter->pen(); 
     226            p.setColor(Qt::black); 
     227            painter->setPen(p); 
     228            painter->drawText(r, Qt::AlignHCenter, m_label); 
     229        } 
     230    } 
    206231} 
    207232 
Note: See TracChangeset for help on using the changeset viewer.