sweet editor now shows GAL canvas

This commit is contained in:
Dick Hollenbeck 2011-11-01 03:05:56 -05:00
parent 8cad403d23
commit 9bf1f390b2
6 changed files with 132 additions and 56 deletions

View File

@ -27,7 +27,7 @@ if( 1 )
project(kicad-new)
cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ )
@ -49,22 +49,6 @@ if( 1 )
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
find_library( gal_LIBRARY "libgal.a"
PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/../../kicad-gal/build"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../kicad-gal/build"
DOC
"Where is the static GAL library"
)
find_path( gal_ROOT NAMES "README.txt"
PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/../../kicad-gal"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../kicad-gal"
DOC
"Where is the base include directory for the GAL library"
)
# make config.h
include( PerformFeatureChecks )
perform_feature_checks()
@ -168,7 +152,46 @@ if( MINGW )
endif()
target_link_libraries( test_sch_lib_table sweet )
include_directories ( "${gal_ROOT}" )
if( 1 )
find_library( gal_LIBRARY "libgal.a"
PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/../../kicad-gal/build"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../kicad-gal/build"
DOC
"Where is the static GAL library"
)
find_path( gal_ROOT NAMES "README.txt"
PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/../../kicad-gal"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../kicad-gal"
DOC
"Where is the base include directory for the GAL library"
)
else()
# we build the GAL library, therefore we know where it is, no need to find_library() it.
set( gal_ROOT "${CMAKE_CURRENT_BINARY_DIR}/gal-src" )
set( gal_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/gal-src/libgal.a" )
include( ExternalProject )
ExternalProject_Add( ki_gal
# skip the install step, build in source, use from source
SOURCE_DIR "${gal_ROOT}"
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/gal-stamps"
TIMEOUT 120
DOWNLOAD_COMMAND bzr export ${gal_ROOT} lp:~kicad-testing-committers/kicad/kicad-gal
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${gal_ROOT}
BUILD_IN_SOURCE 1
BUILD_COMMAND make
INSTALL_COMMAND ""
)
endif()
include_directories( "${gal_ROOT}" )
# Find pkg-config in order find cairo.
find_package( PkgConfig REQUIRED )

View File

@ -31,8 +31,10 @@ namespace SCH {
CANVAS::CANVAS( wxWindow* aParent ) :
OPENGL_GAL( aParent, wxDefaultSize )
OPENGL_GAL( aParent, NULL, this ) // I am my own PaintListener
{
Connect( EVT_GAL_REDRAW, wxCommandEventHandler( CANVAS::onRedraw ) );
// Set the world unit length
SetWorldUnitLength( 0.01 );
@ -63,9 +65,18 @@ CANVAS::CANVAS( wxWindow* aParent ) :
}
void CANVAS::Paint()
void CANVAS::onRedraw( wxCommandEvent& event )
{
/*
D(printf( "%s:\n", __FUNCTION__ );)
PaintScene();
}
void CANVAS::PaintScene()
{
D(printf("%s:\n", __FUNCTION__ );)
BeginDrawing();
SetBackgroundColor( COLOR4D( 0, 0, 0, 1.0 ) );
@ -80,7 +91,6 @@ void CANVAS::Paint()
Flush();
EndDrawing();
*/
}

View File

@ -38,16 +38,11 @@ class CANVAS : public OPENGL_GAL
protected:
PART* part; ///< which PART to draw
void onRedraw( wxCommandEvent& event );
public:
CANVAS( wxWindow* aParent );
/**
* Function Paint (overloaded)
* redraws the entire window, overloads OPENGL_GAL::Paint()
*/
void Paint();
/**
* Function SetPart
* sets the PART to draw, returns the previous PART.
@ -58,6 +53,8 @@ public:
part = aPart;
return ret;
}
void PaintScene();
};

View File

@ -68,30 +68,27 @@ private:
bool m_isReady;
bool m_isPanning;
GRAPHICS_ABSTRACTION_LAYER* m_gal;
SCH::CANVAS* m_gal;
wxSize m_screenSize;
VECTOR2D m_worldSize;
VECTOR2D m_startMousePoint;
VECTOR2D m_startLookAtPoint;
/*
double m_alpha;
VECTOR2D m_startMousePoint;
VECTOR2D m_startLookAtPoint;
MATRIX3x3D m_startMatrix;
STROKE_FONT m_font;
*/
// Event handlers
/*
void OnTimerEvent( wxTimerEvent &event );
void OnMotion( wxMouseEvent& event );
void OnMouseWheel( wxMouseEvent& event );
void OnRedraw( wxCommandEvent& event );
void OnRightDown( wxMouseEvent& event );
void OnRightUp( wxMouseEvent& event );
*/
// void OnRedraw( wxCommandEvent& event );
};
@ -100,17 +97,24 @@ SWEET_FRAME::SWEET_FRAME( wxWindow* parent, wxWindowID id, const wxString& title
wxFrame( parent, id, title, pos, size ),
m_screenSize( size.x, size.y )
{
new SWEET_EDITOR_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), wxSize( -1, -1 ), 0 );
m_isPanning = false;
// Connect( wxEVT_TIMER, wxTimerEventHandler( SWEET_FRAME::OnTimerEvent ) );
SWEET_EDITOR_PANEL* panel =
new SWEET_EDITOR_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), wxSize( -1, -1 ), 0 );
m_gal = (SCH::CANVAS*) panel->FindWindowByName( wxT( "GLCanvas" ), panel );
wxASSERT( m_gal );
m_gal->SetMouseListener( this );
/*
Connect( EVT_GAL_REDRAW, wxCommandEventHandler( SWEET_FRAME::OnRedraw ) );
Connect( wxEVT_MOTION, wxMouseEventHandler( SWEET_FRAME::OnMotion ) );
Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( SWEET_FRAME::OnMouseWheel ) );
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( SWEET_FRAME::OnRightDown ) );
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( SWEET_FRAME::OnRightUp ) );
*/
// Connect( EVT_GAL_REDRAW, wxCommandEventHandler( SWEET_FRAME::OnRedraw ) );
/*
// Set the world unit length
@ -140,8 +144,50 @@ SWEET_FRAME::~SWEET_FRAME()
}
void SWEET_FRAME::OnMotion( wxMouseEvent& event )
{
VECTOR2D mousePoint( event.GetX(), event.GetY() );
// void PaintScene();
if( event.Dragging() )
{
if( m_isPanning )
{
MATRIX3x3D matrix = m_gal->GetWorldScreenMatrix().Inverse();
VECTOR2D delta = matrix.GetScale().x * ( m_startMousePoint - mousePoint );
m_gal->SetLookAtPoint( m_startLookAtPoint + delta );
m_gal->PaintScene();
}
}
else
{
m_gal->DrawCursor( mousePoint );
}
}
void SWEET_FRAME::OnMouseWheel( wxMouseEvent& event )
{
double zoomScale = ( event.GetWheelRotation() > 0.0 ) ? 1.1 : 0.9;
m_gal->SetZoomFactor( m_gal->GetZoomFactor() * zoomScale );
m_gal->PaintScene();
}
void SWEET_FRAME::OnRightDown( wxMouseEvent& event )
{
m_isPanning = true;
m_startMousePoint = VECTOR2D( event.GetX(), event.GetY() );
m_startLookAtPoint = m_gal->GetLookAtPoint();
}
void SWEET_FRAME::OnRightUp( wxMouseEvent& event )
{
m_isPanning = false;
}
static const wxCmdLineEntryDesc g_cmdLineDesc[] = {

View File

@ -36,13 +36,13 @@ SWEET_EDITOR_PANEL::SWEET_EDITOR_PANEL( wxWindow* parent, wxWindowID id, const w
m_scrolledTextWindow->SetSizer( m_scrolledTextSizer );
m_scrolledTextWindow->Layout();
m_scrolledTextSizer->Fit( m_scrolledTextWindow );
m_gal_scrolled_window = new wxScrolledWindow( m_splitter3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
m_gal_scrolled_window = new wxScrolledWindow( m_splitter3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE|wxHSCROLL|wxVSCROLL );
m_gal_scrolled_window->SetScrollRate( 5, 5 );
wxStaticBoxSizer* m_gal_sizer;
m_gal_sizer = new wxStaticBoxSizer( new wxStaticBox( m_gal_scrolled_window, wxID_ANY, _("Visual Part") ), wxVERTICAL );
m_gal = new SCH::CANVAS( m_gal_scrolled_window );
m_gal_sizer->Add( m_gal, 0, wxALL, 5 );
m_gal_sizer->Add( m_gal, 1, wxEXPAND, 5 );
m_gal_scrolled_window->SetSizer( m_gal_sizer );
m_gal_scrolled_window->Layout();

View File

@ -462,7 +462,7 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxStaticBoxSizer" expanded="1">
<object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property>
<property name="label">Sweet</property>
<property name="minimum_size"></property>
@ -470,11 +470,11 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -564,8 +564,8 @@
</object>
</object>
</object>
<object class="splitteritem" expanded="1">
<object class="wxScrolledWindow" expanded="1">
<object class="splitteritem" expanded="0">
<object class="wxScrolledWindow" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -621,7 +621,7 @@
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxHSCROLL|wxVSCROLL</property>
<property name="window_style">wxFULL_REPAINT_ON_RESIZE|wxHSCROLL|wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -645,7 +645,7 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxStaticBoxSizer" expanded="1">
<object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property>
<property name="label">Visual Part</property>
<property name="minimum_size"></property>
@ -653,11 +653,11 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="CustomControl" expanded="1">
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="CustomControl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -672,7 +672,7 @@
<property name="close_button">1</property>
<property name="construction">m_gal = new SCH::CANVAS( m_gal_scrolled_window );</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="context_menu">0</property>
<property name="declaration">SCH::CANVAS* m_gal;</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
@ -716,7 +716,7 @@
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="window_style">wxFULL_REPAINT_ON_RESIZE</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>