Commit c5f24127 authored by Dick Hollenbeck's avatar Dick Hollenbeck

sweet editor using GAL, links but does not work

parent 30a4bd39
set( STAND_ALONE true )
# This program source code file is part of KICAD, a free EDA CAD application.
#
# Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
# Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors#.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you may find one here:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# or you may search the http://www.gnu.org website for the version 2 license,
# or you may write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
# for now, this is a stand alone project
if( 1 )
if( STAND_ALONE )
project(kicad-new)
cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
set( PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ )
# message( "PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" )
# Path to local CMake modules.
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
......@@ -24,8 +49,24 @@ if( STAND_ALONE )
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)
include( PerformFeatureChecks )
perform_feature_checks()
# Include wxWidgets macros.
......@@ -49,7 +90,6 @@ if( STAND_ALONE )
endif()
#================================================
# Doxygen Output
#================================================
......@@ -129,6 +169,40 @@ endif()
target_link_libraries( test_sch_lib_table sweet )
include_directories ("${gal_ROOT}/gal/cairo")
include_directories( "${gal_ROOT}/gal/common" )
include_directories ("${gal_ROOT}/gal/font")
include_directories ("${gal_ROOT}/gal/opengl")
include_directories ("${gal_ROOT}/math")
# Find pkg-config in order find cairo.
find_package( PkgConfig REQUIRED )
# Find cairo.
pkg_search_module( CAIRO REQUIRED cairo>=1.8.1 )
include_directories( ${CAIRO_INCLUDE_DIRS} )
# Find the OpenGL libraries (gl and glu)
find_package( OpenGL )
# Find GLEW
pkg_search_module( GLEW REQUIRED glew>=1.5.0 )
include_directories( ${GLEW_INCLUDE_DIRS} )
include_directories( ${gal_ROOT} )
add_executable( sweet_edit sweet_edit.cpp sweet_editor_panel.cpp )
target_link_libraries( sweet_edit
${OPENGL_LIBRARIES}
${gal_LIBRARY}
${wxWidgets_LIBRARIES}
${GLEW_LIBRARIES}
${GDI_PLUS_LIBRARIES}
)
#=====<USE_SWIG>============================================================
# if you want a Python scripting layer on top for unit testing or driving.
# reference: http://www.swig.org/Doc1.3/Introduction.html#Introduction_build_system
......
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
// wxWidgets imports
#include <wx/wx.h>
#include <wx/graphics.h>
#include <wx/timer.h>
#include <wx/event.h>
#include <wx/wxprec.h>
#include <wx/cmdline.h>
// Graphics Abstraction Layer imports
#include <gal/common/definitions.h>
#include <gal/common/graphics_abstraction_layer.h>
#include <gal/cairo/cairo_gal.h>
#include <gal/opengl/opengl_gal.h>
#include <gal/common/stroke_font.h>
#include <gal/common/color4d.h>
#include "gal/font/newstroke_font.h"
#include <math/vector2d.h>
#include <math/matrix3x3.h>
#include "sweet_editor_panel.h"
#define screenSizeX 640
#define screenSizeY 480
/**
* Class SWEET_EDIT
* implements an editor for SWEET, including support for inheritance and
* LIB_TABLE configuration.
*/
class SWEET_FRAME: public wxFrame
{
public:
// @brief Constructor
SWEET_FRAME( wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size );
// @brief Destructor
~SWEET_FRAME();
private:
bool m_isReady;
bool m_isPanning;
GRAPHICS_ABSTRACTION_LAYER* m_gal;
wxSize m_screenSize;
VECTOR2D m_worldSize;
/*
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 );
*/
};
SWEET_FRAME::SWEET_FRAME( wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size ) :
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 );
// Connect( wxEVT_TIMER, wxTimerEventHandler( SWEET_FRAME::OnTimerEvent ) );
/*
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 ) );
*/
/*
// Set the world unit length
m_gal->SetWorldUnitLength( 0.01 );
m_gal->SetScreenDPI( 100 );
m_gal->SetLookAtPoint( VECTOR2D( size.x / 2, size.y / 2 ) );
m_gal->ComputeWorldScreenMatrix();
// Compute the world size
m_worldSize = VECTOR2D( m_screenSize.x, m_screenSize.y );
// Load Font
if( !m_font.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize ) )
{
cout << "Loading of the font failed." << endl;
}
m_font.SetGraphicsAbstractionLayer( m_gal );
*/
}
SWEET_FRAME::~SWEET_FRAME()
{
delete m_gal;
}
// void PaintScene();
static const wxCmdLineEntryDesc g_cmdLineDesc[] = {
{
wxCMD_LINE_PARAM,
NULL,
NULL,
#if wxCHECK_VERSION( 2, 9, 0 )
"filename of libtable",
#else
wxT( "filename of libtable" ),
#endif
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE
},
{ wxCMD_LINE_NONE }
};
class GAL_TEST_APPLICATION: public wxApp
{
public:
GAL_TEST_APPLICATION();
private:
virtual bool OnInit();
virtual int OnExit();
virtual int OnRun();
virtual void OnInitCmdLine( wxCmdLineParser& aParser );
virtual bool OnCmdLineParsed( wxCmdLineParser& aParser );
};
GAL_TEST_APPLICATION::GAL_TEST_APPLICATION()
{
}
bool GAL_TEST_APPLICATION::OnInit()
{
if ( !wxApp::OnInit() )
return false;
SWEET_FRAME* frame = new SWEET_FRAME( (wxFrame *) NULL,
-1, wxT( "SWEET Editor" ),
wxPoint( screenSizeX + 10, 0 ),
wxSize( screenSizeX, screenSizeY ) );
frame->Show( true );
return true;
}
int GAL_TEST_APPLICATION::OnExit()
{
return 0;
}
int GAL_TEST_APPLICATION::OnRun()
{
int exitcode = wxApp::OnRun();
return exitcode;
}
void GAL_TEST_APPLICATION::OnInitCmdLine( wxCmdLineParser& parser )
{
parser.SetDesc( g_cmdLineDesc );
parser.SetSwitchChars( wxT( "-" ) );
}
bool GAL_TEST_APPLICATION::OnCmdLineParsed( wxCmdLineParser& parser )
{
return true;
}
DECLARE_APP( GAL_TEST_APPLICATION )
IMPLEMENT_APP( GAL_TEST_APPLICATION )
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 6 2011)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "sweet_editor_panel.h"
///////////////////////////////////////////////////////////////////////////
SWEET_EDITOR_PANEL::SWEET_EDITOR_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
{
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxVERTICAL );
m_top_bottom = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_top_bottom->SetSashGravity( 1 );
m_top_bottom->Connect( wxEVT_IDLE, wxIdleEventHandler( SWEET_EDITOR_PANEL::m_top_bottomOnIdle ), NULL, this );
m_panel9 = new wxPanel( m_top_bottom, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxVERTICAL );
m_splitter3 = new wxSplitterWindow( m_panel9, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_splitter3->Connect( wxEVT_IDLE, wxIdleEventHandler( SWEET_EDITOR_PANEL::m_splitter3OnIdle ), NULL, this );
m_scrolledTextWindow = new wxScrolledWindow( m_splitter3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
m_scrolledTextWindow->SetScrollRate( 5, 5 );
wxStaticBoxSizer* m_scrolledTextSizer;
m_scrolledTextSizer = new wxStaticBoxSizer( new wxStaticBox( m_scrolledTextWindow, wxID_ANY, _("Sweet") ), wxVERTICAL );
m_sweet_scroll_window = new wxTextCtrl( m_scrolledTextWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxALWAYS_SHOW_SB );
m_scrolledTextSizer->Add( m_sweet_scroll_window, 1, wxALL|wxEXPAND, 5 );
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->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 OPENGL_GAL( m_gal_scrolled_window, size );
m_gal_sizer->Add( m_gal, 0, wxALL, 5 );
m_gal_scrolled_window->SetSizer( m_gal_sizer );
m_gal_scrolled_window->Layout();
m_gal_sizer->Fit( m_gal_scrolled_window );
m_splitter3->SplitVertically( m_scrolledTextWindow, m_gal_scrolled_window, 0 );
bSizer10->Add( m_splitter3, 1, wxEXPAND, 5 );
m_panel9->SetSizer( bSizer10 );
m_panel9->Layout();
bSizer10->Fit( m_panel9 );
m_scrolledWindow3 = new wxScrolledWindow( m_top_bottom, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
m_scrolledWindow3->SetScrollRate( 5, 5 );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( m_scrolledWindow3, wxID_ANY, _("Parsing Errors") ), wxVERTICAL );
m_htmlWin2 = new wxHtmlWindow( m_scrolledWindow3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
sbSizer1->Add( m_htmlWin2, 1, wxALL|wxEXPAND, 5 );
m_scrolledWindow3->SetSizer( sbSizer1 );
m_scrolledWindow3->Layout();
sbSizer1->Fit( m_scrolledWindow3 );
m_top_bottom->SplitHorizontally( m_panel9, m_scrolledWindow3, 0 );
bSizer2->Add( m_top_bottom, 1, wxEXPAND, 5 );
this->SetSizer( bSizer2 );
this->Layout();
}
SWEET_EDITOR_PANEL::~SWEET_EDITOR_PANEL()
{
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 6 2011)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __sweet_editor_panel__
#define __sweet_editor_panel__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/scrolwin.h>
#include <opengl_gal.h>
#include <wx/splitter.h>
#include <wx/panel.h>
#include <wx/html/htmlwin.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class SWEET_EDITOR_PANEL
///////////////////////////////////////////////////////////////////////////////
class SWEET_EDITOR_PANEL : public wxPanel
{
private:
protected:
wxSplitterWindow* m_top_bottom;
wxPanel* m_panel9;
wxSplitterWindow* m_splitter3;
wxScrolledWindow* m_scrolledTextWindow;
wxTextCtrl* m_sweet_scroll_window;
wxScrolledWindow* m_gal_scrolled_window;
OPENGL_GAL* m_gal;
wxScrolledWindow* m_scrolledWindow3;
wxHtmlWindow* m_htmlWin2;
public:
SWEET_EDITOR_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL );
~SWEET_EDITOR_PANEL();
void m_top_bottomOnIdle( wxIdleEvent& )
{
m_top_bottom->SetSashPosition( 0 );
m_top_bottom->Disconnect( wxEVT_IDLE, wxIdleEventHandler( SWEET_EDITOR_PANEL::m_top_bottomOnIdle ), NULL, this );
}
void m_splitter3OnIdle( wxIdleEvent& )
{
m_splitter3->SetSashPosition( 0 );
m_splitter3->Disconnect( wxEVT_IDLE, wxIdleEventHandler( SWEET_EDITOR_PANEL::m_splitter3OnIdle ), NULL, this );
}
};
#endif //__sweet_editor_panel__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment