/** * Inserts a point at the given index. */ bool LinePath::insertPoint( int pointIndex, const QPoint &point ) { int count = m_LineList.count(); if( count == 0 ) return false; const bool bLoading = UMLApp::app()->document()->loading(); if( count == 1 || pointIndex == 1) { Q3CanvasLine * first = m_LineList.first(); QPoint sp = first -> startPoint(); QPoint ep = first -> endPoint(); first -> setPoints( sp.x(), sp.y(), point.x(), point.y() ); Q3CanvasLine * line = new Q3CanvasLine( getScene() ); line -> setZ( -2 ); line -> setPoints( point.x(), point.y(), ep.x(), ep.y() ); line -> setPen( getPen() ); line -> setVisible( true ); m_LineList.insert( 1, line ); if (!bLoading) setupSelected(); return true; } if( count + 1 == pointIndex ) { Q3CanvasLine * before = m_LineList.last(); QPoint sp = before -> startPoint(); QPoint ep = before -> endPoint(); before -> setPoints( sp.x(), sp.y(), point.x(), point.y() ); Q3CanvasLine * line = new Q3CanvasLine( getScene() ); line -> setPoints( point.x(), point.y(), ep.x(), ep.y() ); line -> setZ( -2 ); line -> setPen( getPen() ); line -> setVisible( true ); m_LineList.append( line ); if (!bLoading) setupSelected(); return true; } Q3CanvasLine * before = m_LineList.at( pointIndex - 1 ); QPoint sp = before -> startPoint(); QPoint ep = before -> endPoint(); before -> setPoints( sp.x(), sp.y(), point.x(), point.y() ); Q3CanvasLine * line = new Q3CanvasLine(getScene() ); line -> setPoints( point.x(), point.y(), ep.x(), ep.y() ); line -> setZ( -2 ); line -> setPen( getPen() ); line -> setVisible( true ); m_LineList.insert( pointIndex, line ); if (!bLoading) setupSelected(); return true; }
void LinePath::moveSelected( int pointIndex ) { int lineCount = m_LineList.count(); if( !m_bSelected ) { m_RectList.clear(); return; } if( (int)m_RectList.count() + 1 != lineCount ) setupSelected(); QCanvasRectangle * rect = 0; QCanvasLine * line = 0; if( pointIndex == lineCount || lineCount == 1) { line = m_LineList.last(); QPoint p = line -> endPoint(); rect = m_RectList.last(); rect -> setX( p.x() ); rect -> setY( p.y() ); rect -> setZ( 4 ); return; } line = m_LineList.at( pointIndex ); QPoint p = line -> startPoint(); rect = m_RectList.at( pointIndex ); rect -> setX( p.x() ); rect -> setY( p.y() ); rect -> setZ( 4 ); }
/** * Sets the status of whether the line is selected or not. */ void LinePath::setSelected( bool select ) { if(select) { setupSelected(); } else if(!m_RectList.isEmpty()) { qDeleteAll(m_RectList); m_RectList.clear(); } }
/** * Sets the status of whether the line is selected or not. */ void AssociationLine::setSelected( bool select ) { if(select) { setupSelected(); } else if(!m_RectList.isEmpty()) { qDeleteAll(m_RectList); m_RectList.clear(); } }
void LinePath::setSelected( bool select ) { if(select) setupSelected(); else if( m_RectList.count() > 0 ) m_RectList.clear(); }