← Back to team overview

kicad-developers team mailing list archive

[PATCH] Footprint text umbilicals

 

Hi,

Here's a proposal for a feature stolen from Eagle (at least). When
moving footprint reference texts around in crowded areas of a board,
it is sometimes difficult to keep track of, e.g., which reference
belongs to which resistor. The situation would be clearer if there was
a line drawn from the reference and other text fields to the parent
footprint origin. That's what the attached patch adds to pcbnew. In
addition it centers the cursor on the field that is being moved when
the move starts.

marco
=== modified file 'pcbnew/class_text_mod.cpp'
--- pcbnew/class_text_mod.cpp	2010-11-12 16:36:43 +0000
+++ pcbnew/class_text_mod.cpp	2010-11-17 20:38:54 +0000
@@ -419,6 +419,22 @@
                      size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
 }
 
+void TEXTE_MODULE::DrawUmbilical( WinEDA_DrawPanel* aPanel,
+                                  wxDC*             aDC,
+                                  int               aDrawMode,
+                                  const wxPoint&    aOffset )
+{
+    MODULE* parent = (MODULE*) GetParent();
+    if( !parent )
+        return;
+
+    GRSetDrawMode( aDC, GR_XOR );
+    GRLine( &aPanel->m_ClipBox, aDC,
+            parent->GetPosition().x, parent->GetPosition().y,
+            GetPosition().x + aOffset.x,
+            GetPosition().y + aOffset.y,
+            0, UMBILICAL_COLOR);
+}
 
 /* Return text rotation for drawings and plotting
  */

=== modified file 'pcbnew/class_text_mod.h'
--- pcbnew/class_text_mod.h	2010-11-12 15:17:10 +0000
+++ pcbnew/class_text_mod.h	2010-11-17 22:10:15 +0000
@@ -11,6 +11,7 @@
 #define TEXT_is_VALUE     1
 #define TEXT_is_DIVERS    2
 
+#define UMBILICAL_COLOR   LIGHTBLUE
 
 class TEXTE_MODULE : public BOARD_ITEM, public EDA_TextStruct
 {
@@ -94,6 +95,19 @@
                    int               aDrawMode,
                    const wxPoint&    offset = ZeroOffset );
 
+    /**
+     * Function DrawUmbilical
+     * draws a line from the TEXTE_MODULE origin
+     * to parent MODULE origin.
+     * @param aPanel = the current DrawPanel
+     * @param aDC = the current device context
+     * @param aDrawMode = drawing mode, typically GR_XOR
+     * @param aOffset = offset for TEXTE_MODULE
+     */
+    void     DrawUmbilical( WinEDA_DrawPanel* aPanel,
+                            wxDC*             aDC,
+                            int               aDrawMode,
+                            const wxPoint&    aOffset = ZeroOffset );
 
     /**
      * Function DisplayInfo

=== modified file 'pcbnew/edtxtmod.cpp'
--- pcbnew/edtxtmod.cpp	2010-07-20 18:11:34 +0000
+++ pcbnew/edtxtmod.cpp	2010-11-17 20:38:54 +0000
@@ -139,6 +139,7 @@
 
     Module = (MODULE*) Text->GetParent();
 
+    Text->DrawUmbilical( Panel, DC, GR_XOR, -MoveVector );
     Text->Draw( Panel, DC, GR_XOR, MoveVector );
 
     // If the text was moved (the move does not change internal data)
@@ -175,9 +176,16 @@
 
     MoveVector.x = MoveVector.y = 0;
 
+    DrawPanel->CursorOff( DC );
+
     TextInitialPosition    = Text->m_Pos;
     TextInitialOrientation = Text->m_Orient;
 
+    // Center cursor on initial position of text
+    GetScreen()->m_Curseur = TextInitialPosition;
+    DrawPanel->MouseToCursorSchema();
+    DrawPanel->CursorOn( DC );
+
     Text->DisplayInfo( this );
 
     SetCurItem( Text );
@@ -195,6 +203,7 @@
     if( Text != NULL )
     {
         DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
+        Text->DrawUmbilical( DrawPanel, DC, GR_XOR, -MoveVector );
 
         /* Update the coordinates for anchor. */
         MODULE* Module = (MODULE*) Text->GetParent();
@@ -242,12 +251,18 @@
     if( Text == NULL )
         return;
 
-    /* Undraw the text */
+    // Erase umbilical and text if necessary
     if( erase )
+    {
+        Text->DrawUmbilical( panel, DC, GR_XOR, -MoveVector );
         Text->Draw( panel, DC, GR_XOR, MoveVector );
+    }
 
     MoveVector = TextInitialPosition - screen->m_Curseur;
 
-    /* Redraw the text */
+    // Draw umbilical if text moved
+    if( MoveVector.x || MoveVector.y )
+        Text->DrawUmbilical( panel, DC, GR_XOR, -MoveVector );
+    // Redraw text
     Text->Draw( panel, DC, GR_XOR, MoveVector );
 }


Follow ups