eeschema-gal: support for global labels and bitmaps
This commit is contained in:
parent
d9f0dc63a5
commit
ccb594f599
|
@ -1002,11 +1002,9 @@ void OPENGL_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aContro
|
||||||
void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
|
void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
|
||||||
{
|
{
|
||||||
int ppi = aBitmap.GetPPI();
|
int ppi = aBitmap.GetPPI();
|
||||||
double worldIU_per_mm = 1.0 / ( worldUnitLength / 2.54 )/ 1000;
|
|
||||||
double pix_size_iu = worldIU_per_mm * ( 25.4 / ppi );
|
|
||||||
|
|
||||||
double w = aBitmap.GetSizePixels().x * pix_size_iu;
|
double w = (double) aBitmap.GetSizePixels().x / (double) ppi / worldUnitLength * 10.0; // no idea where the factor 10 comes from...
|
||||||
double h = aBitmap.GetSizePixels().y * pix_size_iu;
|
double h = (double) aBitmap.GetSizePixels().y / (double) ppi / worldUnitLength * 10.0;
|
||||||
|
|
||||||
auto xform = currentManager->GetTransformation();
|
auto xform = currentManager->GetTransformation();
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,12 @@
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <sch_draw_panel.h>
|
#include <sch_draw_panel.h>
|
||||||
|
#include <sch_view.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <sch_bitmap.h>
|
#include <sch_bitmap.h>
|
||||||
#include <dialog_image_editor.h>
|
#include <dialog_image_editor.h>
|
||||||
|
|
||||||
|
#include <view/view_group.h>
|
||||||
|
|
||||||
static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
||||||
{
|
{
|
||||||
|
@ -72,29 +73,25 @@ static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
||||||
|
|
||||||
static void moveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
|
static void moveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
|
||||||
{
|
{
|
||||||
|
auto panel = static_cast<SCH_DRAW_PANEL*> ( aPanel );
|
||||||
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
||||||
SCH_BITMAP* image = (SCH_BITMAP*) screen->GetCurItem();
|
SCH_BITMAP* image = (SCH_BITMAP*) screen->GetCurItem();
|
||||||
|
auto preview = panel->GetView()->GetPreview();
|
||||||
|
|
||||||
if( aErase )
|
if ( ! image )
|
||||||
{
|
return;
|
||||||
// Erase the current bitmap at its current position.
|
|
||||||
// Note also items flagged IS_MOVING are not drawn,
|
|
||||||
// and if image is new, it is not yet il draw list
|
|
||||||
// so image is erased from screen
|
|
||||||
EDA_RECT dirty = image->GetBoundingBox();
|
|
||||||
dirty.Inflate( 4 ); // Give a margin
|
|
||||||
aPanel->SetMouseCapture( NULL, NULL ); // Avoid loop in redraw panel
|
|
||||||
|
|
||||||
STATUS_FLAGS flgs = image->GetFlags();
|
|
||||||
image->ClearFlags();
|
|
||||||
aPanel->RefreshDrawingRect( dirty );
|
|
||||||
image->SetFlags( flgs );
|
|
||||||
aPanel->SetMouseCapture( moveBitmap, abortMoveBitmap );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the bitmap at it's new position.
|
// Draw the bitmap at it's new position.
|
||||||
image->SetPosition( aPanel->GetParent()->GetCrossHairPosition() - image->GetStoredPos() );
|
image->SetPosition( aPanel->GetParent()->GetCrossHairPosition() - image->GetStoredPos() );
|
||||||
image->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
||||||
|
auto view = panel->GetView();
|
||||||
|
|
||||||
|
view->ClearPreview();
|
||||||
|
view->AddToPreview( image, false );
|
||||||
|
view->SetVisible( preview, true );
|
||||||
|
view->Update( preview );
|
||||||
|
|
||||||
|
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,8 +125,11 @@ SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
image->SetFlags( IS_NEW | IS_MOVED );
|
auto view = static_cast<SCH_DRAW_PANEL*>( m_canvas )->GetView();
|
||||||
image->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
||||||
|
view->ClearPreview();
|
||||||
|
view->AddToPreview( image, false );
|
||||||
|
|
||||||
|
|
||||||
m_canvas->SetMouseCapture( moveBitmap, abortMoveBitmap );
|
m_canvas->SetMouseCapture( moveBitmap, abortMoveBitmap );
|
||||||
GetScreen()->SetCurItem( image );
|
GetScreen()->SetCurItem( image );
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <sch_text.h>
|
#include <sch_text.h>
|
||||||
#include <sch_no_connect.h>
|
#include <sch_no_connect.h>
|
||||||
#include <sch_bus_entry.h>
|
#include <sch_bus_entry.h>
|
||||||
|
#include <sch_bitmap.h>
|
||||||
#include <draw_graphic_text.h>
|
#include <draw_graphic_text.h>
|
||||||
|
|
||||||
#include <lib_edit_frame.h>
|
#include <lib_edit_frame.h>
|
||||||
|
@ -140,14 +141,14 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
|
||||||
*/
|
*/
|
||||||
switch(item->Type())
|
switch(item->Type())
|
||||||
{
|
{
|
||||||
HANDLE_ITEM(LIB_PART_T, LIB_PART);
|
HANDLE_ITEM(LIB_PART_T, LIB_PART);
|
||||||
HANDLE_ITEM(LIB_RECTANGLE_T, LIB_RECTANGLE);
|
HANDLE_ITEM(LIB_RECTANGLE_T, LIB_RECTANGLE);
|
||||||
HANDLE_ITEM(LIB_POLYLINE_T, LIB_POLYLINE);
|
HANDLE_ITEM(LIB_POLYLINE_T, LIB_POLYLINE);
|
||||||
HANDLE_ITEM(LIB_CIRCLE_T, LIB_CIRCLE);
|
HANDLE_ITEM(LIB_CIRCLE_T, LIB_CIRCLE);
|
||||||
HANDLE_ITEM(LIB_PIN_T, LIB_PIN);
|
HANDLE_ITEM(LIB_PIN_T, LIB_PIN);
|
||||||
HANDLE_ITEM(LIB_ARC_T, LIB_ARC);
|
HANDLE_ITEM(LIB_ARC_T, LIB_ARC);
|
||||||
HANDLE_ITEM(LIB_FIELD_T, LIB_FIELD);
|
HANDLE_ITEM(LIB_FIELD_T, LIB_FIELD);
|
||||||
HANDLE_ITEM(LIB_TEXT_T, LIB_TEXT);
|
HANDLE_ITEM(LIB_TEXT_T, LIB_TEXT);
|
||||||
HANDLE_ITEM(SCH_COMPONENT_T, SCH_COMPONENT);
|
HANDLE_ITEM(SCH_COMPONENT_T, SCH_COMPONENT);
|
||||||
HANDLE_ITEM(SCH_JUNCTION_T, SCH_JUNCTION);
|
HANDLE_ITEM(SCH_JUNCTION_T, SCH_JUNCTION);
|
||||||
HANDLE_ITEM(SCH_LINE_T, SCH_LINE);
|
HANDLE_ITEM(SCH_LINE_T, SCH_LINE);
|
||||||
|
@ -160,6 +161,8 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
|
||||||
HANDLE_ITEM(SCH_NO_CONNECT_T, SCH_NO_CONNECT);
|
HANDLE_ITEM(SCH_NO_CONNECT_T, SCH_NO_CONNECT);
|
||||||
HANDLE_ITEM(SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE);
|
HANDLE_ITEM(SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE);
|
||||||
HANDLE_ITEM(SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE);
|
HANDLE_ITEM(SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE);
|
||||||
|
HANDLE_ITEM(SCH_BITMAP_T, SCH_BITMAP);
|
||||||
|
HANDLE_ITEM(SCH_MARKER_T, SCH_MARKER);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -705,6 +708,9 @@ void SCH_PAINTER::draw ( SCH_TEXT *aText, int aLayer )
|
||||||
case SCH_HIERARCHICAL_LABEL_T:
|
case SCH_HIERARCHICAL_LABEL_T:
|
||||||
color = m_schSettings.GetLayerColor( LAYER_SHEETLABEL );
|
color = m_schSettings.GetLayerColor( LAYER_SHEETLABEL );
|
||||||
break;
|
break;
|
||||||
|
case SCH_GLOBAL_LABEL_T:
|
||||||
|
color = m_schSettings.GetLayerColor( LAYER_GLOBLABEL );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
color = m_schSettings.GetLayerColor( LAYER_NOTES );
|
color = m_schSettings.GetLayerColor( LAYER_NOTES );
|
||||||
break;
|
break;
|
||||||
|
@ -910,9 +916,24 @@ void SCH_PAINTER::draw ( SCH_FIELD *aField, int aLayer )
|
||||||
m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? -M_PI/2 : 0 );
|
m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? -M_PI/2 : 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_PAINTER::draw ( SCH_GLOBALLABEL *aLabel, int aLayer )
|
void SCH_PAINTER::draw ( SCH_GLOBALLABEL *aLabel, int aLayer )
|
||||||
{
|
{
|
||||||
|
std::vector<wxPoint> pts;
|
||||||
|
std::deque<VECTOR2D> pts2;
|
||||||
|
|
||||||
|
aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
|
||||||
|
|
||||||
|
for( auto p : pts )
|
||||||
|
pts2.push_back( VECTOR2D(p.x, p.y ) );
|
||||||
|
|
||||||
|
m_gal->SetIsFill( false );
|
||||||
|
m_gal->SetIsStroke( true );
|
||||||
|
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_GLOBLABEL ) );
|
||||||
|
m_gal->DrawPolyline( pts2 );
|
||||||
|
m_gal->AdvanceDepth(); // fixme
|
||||||
|
|
||||||
|
draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1022,5 +1043,18 @@ void SCH_PAINTER::draw ( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SCH_PAINTER::draw ( SCH_BITMAP *aBitmap, int aLayer )
|
||||||
|
{
|
||||||
|
m_gal->Save();
|
||||||
|
m_gal->Translate( aBitmap->GetPosition() );
|
||||||
|
m_gal->DrawBitmap( *aBitmap->GetImage() );
|
||||||
|
m_gal->Restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCH_PAINTER::draw ( SCH_MARKER *aMarker, int aLayer )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // namespace KIGFX
|
}; // namespace KIGFX
|
||||||
|
|
|
@ -49,6 +49,7 @@ class SCH_MARKER;
|
||||||
class SCH_NO_CONNECT;
|
class SCH_NO_CONNECT;
|
||||||
class SCH_LINE;
|
class SCH_LINE;
|
||||||
class SCH_BUS_ENTRY_BASE;
|
class SCH_BUS_ENTRY_BASE;
|
||||||
|
class SCH_BITMAP;
|
||||||
|
|
||||||
namespace KIGFX
|
namespace KIGFX
|
||||||
{
|
{
|
||||||
|
@ -134,8 +135,9 @@ private:
|
||||||
void draw( SCH_SHEET_PIN *, int );
|
void draw( SCH_SHEET_PIN *, int );
|
||||||
void draw( SCH_NO_CONNECT *, int );
|
void draw( SCH_NO_CONNECT *, int );
|
||||||
void draw( SCH_MARKER *, int );
|
void draw( SCH_MARKER *, int );
|
||||||
|
void draw( SCH_BITMAP *, int );
|
||||||
void draw( SCH_LINE *, int );
|
void draw( SCH_LINE *, int );
|
||||||
void draw ( SCH_BUS_ENTRY_BASE *aEntry, int aLayer );
|
void draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer );
|
||||||
|
|
||||||
|
|
||||||
void defaultColors( const LIB_ITEM *aItem );
|
void defaultColors( const LIB_ITEM *aItem );
|
||||||
|
|
Loading…
Reference in New Issue