Resync with main branch and fixed to work with new symbol visibility rules

This commit is contained in:
Cirilo Bernardo 2015-12-09 09:52:02 +11:00
commit 2ba7c05cbf
34 changed files with 334 additions and 502 deletions

View File

@ -4,7 +4,6 @@ include_directories(
${CMAKE_SOURCE_DIR}/3d-viewer
)
add_library( s3d_sg SHARED
sg_base.cpp
sg_node.cpp
@ -33,10 +32,8 @@ add_library( s3d_sg SHARED
ifsg_api.cpp
)
if( MSVC )
# Define a flag to expose the appropriate SG_DLL macro at build time
target_compile_definitions( s3d_sg PRIVATE -DDLL_SGIF )
endif()
# Define a flag to expose the appropriate EXPORT macro at build time
target_compile_definitions( s3d_sg PRIVATE -DCOMPILE_SGLIB )
target_link_libraries( s3d_sg ${wxWidgets_LIBRARIES} )

View File

@ -1,149 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
*/
#include <iostream>
#include "sg_api.h"
#include "sg_node.h"
S3D::API_SGNODE::API_SGNODE()
{
node = NULL;
nodeType = SGTYPE_END; // signal an invalid type by default
return;
}
SGNODE* S3D::API_SGNODE::GetNode( void )
{
return node;
}
bool S3D::API_SGNODE::AttachNode( SGNODE* aNode )
{
if( NULL == aNode )
{
node = NULL;
return true;
}
if( aNode->GetNodeType() != nodeType )
{
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
std::cerr << " * [BUG] object with node type " << aNode->GetNodeType();
std::cerr << " is being attached to API node type " << nodeType << "\n";
return false;
}
node = aNode;
return true;
}
bool S3D::API_SGNODE::GetNodeType( S3D::SGTYPES& aNodeType ) const
{
if( NULL == node )
{
aNodeType = SGTYPE_END;
return false;
}
aNodeType = node->GetNodeType();
return true;
}
bool S3D::API_SGNODE::GetParent( SGNODE const*& aParent ) const
{
if( NULL == node )
{
aParent = NULL;
return false;
}
aParent = node->GetParent();
return true;
}
bool S3D::API_SGNODE::SetParent( SGNODE* aParent )
{
if( NULL == node )
return false;
return node->SetParent( aParent );
}
bool S3D::API_SGNODE::GetName( const char*& aName )
{
if( NULL == node )
{
aName = NULL;
return false;
}
aName = node->GetName();
return true;
}
bool S3D::API_SGNODE::SetName( const char *aName )
{
if( NULL == node )
return false;
node->SetName( aName );
return true;
}
bool S3D::API_SGNODE::GetNodeTypeName( S3D::SGTYPES aNodeType, const char*& aName ) const
{
if( NULL == node )
{
aName = NULL;
return false;
}
aName = node->GetNodeTypeName( aNodeType );
return true;
}
bool S3D::API_SGNODE::FindNode( const char *aNodeName, const SGNODE *aCaller, SGNODE*& aNode )
{
if( NULL == node )
{
aNode = NULL;
return false;
}
aNode = node->FindNode( aNodeName, aCaller );
if( NULL == aNode )
return false;
return true;
}

View File

@ -1,26 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
*/
#include <3d_cache/sg/sg_api.h>
XXX - TO BE IMPLEMENTED

View File

@ -26,13 +26,13 @@
* collects header files for all SG* wrappers and the API
*/
#include <3d_cache/sg/ifsg_transform.h>
#include <3d_cache/sg/ifsg_appearance.h>
#include <3d_cache/sg/ifsg_colors.h>
#include <3d_cache/sg/ifsg_coords.h>
#include <3d_cache/sg/ifsg_faceset.h>
#include <3d_cache/sg/ifsg_colorindex.h>
#include <3d_cache/sg/ifsg_coordindex.h>
#include <3d_cache/sg/ifsg_normals.h>
#include <3d_cache/sg/ifsg_shape.h>
#include <3d_cache/sg/ifsg_api.h>
#include "3d_cache/sg/ifsg_transform.h"
#include "3d_cache/sg/ifsg_appearance.h"
#include "3d_cache/sg/ifsg_colors.h"
#include "3d_cache/sg/ifsg_coords.h"
#include "3d_cache/sg/ifsg_faceset.h"
#include "3d_cache/sg/ifsg_colorindex.h"
#include "3d_cache/sg/ifsg_coordindex.h"
#include "3d_cache/sg/ifsg_normals.h"
#include "3d_cache/sg/ifsg_shape.h"
#include "3d_cache/sg/ifsg_api.h"

View File

@ -30,10 +30,13 @@
#define IFSG_API_H
#include <wx/string.h>
#include <glm/glm.hpp>
#include <3d_cache/sg/sg_types.h>
#include <3d_cache/sg/sg_base.h>
#include <3d_rendering/c3dmodel.h>
#include <glm.hpp>
#include "3d_cache/sg/sg_types.h"
#include "3d_cache/sg/sg_base.h"
#include "3d_rendering/c3dmodel.h"
#include "ifsg_defs.h"
class SGNODE;
class SCENEGRAPH;
@ -51,7 +54,7 @@ namespace S3D
* @param aNode is any node within the node tree which is to be written
* @return true on success
*/
bool WriteCache( const wxString& aFileName, bool overwrite, SGNODE* aNode );
SGLIB_API bool WriteCache( const wxString& aFileName, bool overwrite, SGNODE* aNode );
/**
* Function ReadCache
@ -62,7 +65,7 @@ namespace S3D
* if desired this node can be associated with an IFSG_TRANSFORM wrapper via
* the IFSG_TRANSFORM::Attach() function.
*/
SGNODE* ReadCache( const wxString& aFileName );
SGLIB_API SGNODE* ReadCache( const wxString& aFileName );
/**
* Function WriteVRML
@ -74,7 +77,7 @@ namespace S3D
* @param reuse should be set to true to make use of VRML DEF/USE features
* @return true on success
*/
bool WriteVRML( const wxString& filename, bool overwrite, SGNODE* aTopNode,
SGLIB_API bool WriteVRML( const wxString& filename, bool overwrite, SGNODE* aTopNode,
bool reuse, bool renameNodes );
// NOTE: The following functions are used in combination to create a VRML
@ -107,7 +110,7 @@ namespace S3D
*
* @param aNode may be any valid SGNODE
*/
void ResetNodeIndex( SGNODE* aNode );
SGLIB_API void ResetNodeIndex( SGNODE* aNode );
/**
* Function RenameNodes
@ -116,7 +119,7 @@ namespace S3D
*
* @param aNode is a top level node
*/
void RenameNodes( SGNODE* aNode );
SGLIB_API void RenameNodes( SGNODE* aNode );
/**
* Function DestroyNode
@ -124,7 +127,7 @@ namespace S3D
* to safely delete an SG* node without associating the node with
* its corresponding IFSG* wrapper.
*/
void DestroyNode( SGNODE* aNode );
SGLIB_API void DestroyNode( SGNODE* aNode );
// NOTE: The following functions facilitate the creation and destruction
// of data structures for rendering
@ -139,44 +142,44 @@ namespace S3D
*
* @return an S3DMODEL representation of aNode on success, otherwise NULL
*/
S3DMODEL* Prepare( SCENEGRAPH* aNode, const glm::dmat4* aTransform );
SGLIB_API S3DMODEL* Prepare( SCENEGRAPH* aNode, const glm::dmat4* aTransform );
/**
* Function Destroy3DModel
* frees memory used by an S3DMODEL structure and sets the pointer to
* the structure to NULL
*/
void Destroy3DModel( S3DMODEL** aModel );
SGLIB_API void Destroy3DModel( S3DMODEL** aModel );
/**
* Function Free3DModel
* frees memory used internally by an S3DMODEL structure
*/
void Free3DModel( S3DMODEL& aModel );
SGLIB_API void Free3DModel( S3DMODEL& aModel );
/**
* Function Free3DMesh
* frees memory used internally by an SMESH structure
*/
void Free3DMesh( SMESH& aMesh );
SGLIB_API void Free3DMesh( SMESH& aMesh );
/**
* Function New3DModel
* creates and initializes an S3DMODEL struct
*/
S3DMODEL* New3DModel( void );
SGLIB_API S3DMODEL* New3DModel( void );
/**
* Function Init3DMaterial
* initializes an SMATERIAL struct
*/
void Init3DMaterial( SMATERIAL& aMat );
SGLIB_API void Init3DMaterial( SMATERIAL& aMat );
/**
* Function Init3DMesh
* creates and initializes an SMESH struct
*/
void Init3DMesh( SMESH& aMesh );
SGLIB_API void Init3DMesh( SMESH& aMesh );
};
#endif // IFSG_API_H

View File

@ -31,8 +31,7 @@
#include <3d_cache/sg/ifsg_node.h>
class IFSG_APPEARANCE : public IFSG_NODE
class SGLIB_API IFSG_APPEARANCE : public IFSG_NODE
{
public:
IFSG_APPEARANCE( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_COLORINDEX
* is the wrapper for SGCOLORINDEX
*/
class SG_DLL IFSG_COLORINDEX : public IFSG_INDEX
class SGLIB_API IFSG_COLORINDEX : public IFSG_INDEX
{
public:
IFSG_COLORINDEX( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_INDEX
* is the wrapper for SGCOLORS
*/
class SG_DLL IFSG_COLORS : public IFSG_NODE
class SGLIB_API IFSG_COLORS : public IFSG_NODE
{
public:
IFSG_COLORS( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_COORDINDEX
* is the wrapper for SGCOORDINDEX
*/
class SG_DLL IFSG_COORDINDEX : public IFSG_INDEX
class SGLIB_API IFSG_COORDINDEX : public IFSG_INDEX
{
public:
IFSG_COORDINDEX( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_INDEX
* is the wrapper for SGCOORDS
*/
class SG_DLL IFSG_COORDS : public IFSG_NODE
class SGLIB_API IFSG_COORDS : public IFSG_NODE
{
public:
IFSG_COORDS( bool create );

View File

@ -1,7 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015 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
@ -21,19 +22,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Note: this is based on kicad's import_export.h file but is
* reproduced here in order to facilitate support of out-of-tree
* builds for 3D plugins.
*/
#ifndef IFSG_DEFS_H
#define IFSG_DEFS_H
#if defined( MSVC )
#if defined( DLL_SGIF )
// we are building the library
#define SG_DLL __declspec( dllexport )
#else
// we must be using the library
#define SG_DLL __declspec( dllimport )
#endif
#if defined(__MINGW32__) || defined( MSVC )
#define APIEXPORT __declspec(dllexport)
#define APIIMPORT __declspec(dllimport)
#define APILOCAL
#elif defined(__GNUC__) && __GNUC__ >= 4
// On ELF, we compile with hidden visibility, so unwrap that for specific symbols:
#define APIEXPORT __attribute__ ((visibility("default")))
#define APIIMPORT __attribute__ ((visibility("default")))
#define APILOCAL __attribute__ ((visibility("hidden")))
#else
#define SG_DLL
#pragma message ( "warning: a supported C++ compiler is required" )
#define APIEXPORT
#define APIIMPORT
#define APILOCAL
#endif
#if defined (COMPILE_SGLIB)
#define SGLIB_API APIEXPORT
#else
#define SGLIB_API APIIMPORT
#endif
#endif // IFSG_DEFS_H

View File

@ -37,7 +37,7 @@
* Class IFSG_FACESET
* is the wrapper for the SGFACESET class
*/
class SG_DLL IFSG_FACESET : public IFSG_NODE
class SGLIB_API IFSG_FACESET : public IFSG_NODE
{
public:
IFSG_FACESET( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_INDEX
* is the wrapper for SGINDEX
*/
class SG_DLL IFSG_INDEX : public IFSG_NODE
class SGLIB_API IFSG_INDEX : public IFSG_NODE
{
public:
IFSG_INDEX();

View File

@ -42,9 +42,9 @@
#ifndef IFSG_NODE_H
#define IFSG_NODE_H
#include <3d_cache/sg/sg_base.h>
#include <3d_cache/sg/sg_types.h>
#include <3d_cache/sg/ifsg_defs.h>
#include "3d_cache/sg/sg_base.h"
#include "3d_cache/sg/sg_types.h"
#include "3d_cache/sg/ifsg_defs.h"
class SGNODE;
@ -52,7 +52,7 @@ class SGNODE;
* Class IFSG_NODE
* represents the base class of all DLL-safe Scene Graph nodes
*/
class SG_DLL IFSG_NODE
class SGLIB_API IFSG_NODE
{
private:
// hide the copy constructors and assignment operator to avoid accidental misuse

View File

@ -37,7 +37,7 @@
* Class IFSG_NORMALINDEX
* is the wrapper for SGNORMALINDEX
*/
class SG_DLL IFSG_NORMALINDEX : public IFSG_INDEX
class SGLIB_API IFSG_NORMALINDEX : public IFSG_INDEX
{
public:
IFSG_NORMALINDEX( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_NORMALS
* is the wrapper for the SGNORMALS class
*/
class SG_DLL IFSG_NORMALS : public IFSG_NODE
class SGLIB_API IFSG_NORMALS : public IFSG_NODE
{
public:
IFSG_NORMALS( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_SHAPE
* is the wrapper for the SGSHAPE class
*/
class SG_DLL IFSG_SHAPE : public IFSG_NODE
class SGLIB_API IFSG_SHAPE : public IFSG_NODE
{
public:
IFSG_SHAPE( bool create );

View File

@ -37,7 +37,7 @@
* Class IFSG_TRANSFORM
* is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH
*/
class SG_DLL IFSG_TRANSFORM : public IFSG_NODE
class SGLIB_API IFSG_TRANSFORM : public IFSG_NODE
{
public:
IFSG_TRANSFORM( bool create );

View File

@ -1,172 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
*/
/**
* @file sg_api.h
* provides the API which plugins require to manipulate the SG* classes.
*
*/
#ifndef SG_API_H
#define SG_API_H
#include <3d_cache/sg/sg_types.h>
class SGCOLOR;
class SGPOINT;
class SGVECTOR;
class SGNODE;
class SCENEGRAPH;
// creation and manipulation of base types
typedef SGCOLOR* (*NEW_SGBASE_COLOR)(void);
typedef bool ( *SET_SGBASE_COLOR )( SGCOLOR* aColor,
float aRedVal, float aGreenVal, float aBlueVal );
typedef bool ( *GET_SGBASE_COLOR )( SGCOLOR* aColor,
float& aRedVal, float& aGreenVal, float& aBlueVal );
typedef SGPOINT* ( *NEW_SGBASE_POINT )(void);
typedef bool ( *SET_SGBASE_POINT )( SGPOINT* aPoint,
double aXVal, double aYVal, double aZVal );
typedef bool ( *GET_SGBASE_POINT )( SGPOINT* aPoint,
double& aXVal, double& aYVal, double& aZVal );
typedef SGVECTOR* (*NEW_SGBASE_VECTOR)(void);
typedef bool ( *SET_SGBASE_VECTOR )( SGPOINT* aVector,
double aXVal, double aYVal, double aZVal );
typedef bool ( *GET_SGBASE_VECTOR )( SGPOINT* aVector,
double& aXVal, double& aYVal, double& aZVal );
// creation of scenegraph nodes:
typedef SGNODE* (*NEW_SG_NODE)( SGNODE* aParent, S3D::SGTYPES aNodeType);
namespace S3D
{
struct SG_API
{
// creation of basic SG types
NEW_SGBASE_COLOR NewColor;
NEW_SGBASE_POINT NewPoint;
NEW_SGBASE_VECTOR NewVector;
// manipulators for basic SG types
SET_SGBASE_COLOR SetSGColor;
GET_SGBASE_COLOR GetSGColor;
SET_SGBASE_POINT SetSGPoint;
GET_SGBASE_POINT GetSGPoint;
SET_SGBASE_VECTOR SetSGVector;
GET_SGBASE_VECTOR GetSGVector;
// creation of nodes
NEW_SG_NODE NewNode;
};
// generic node class; this must never be instantiated as an underived class
class API_SGNODE
{
protected:
SGNODE* node;
S3D::SGTYPES nodeType;
public:
API_SGNODE();
SGNODE* GetNode( void );
bool AttachNode( SGNODE* aNode );
bool GetNodeType( S3D::SGTYPES& aNodeType ) const;
bool GetParent( SGNODE const*& aParent ) const;
bool SetParent( SGNODE* aParent );
bool GetName( const char*& aName );
bool SetName( const char *aName );
bool GetNodeTypeName( S3D::SGTYPES aNodeType, const char*& aName ) const;
bool FindNode( const char *aNodeName, const SGNODE *aCaller, SGNODE*& aNode );
};
// Transforms and operations
class API_TRANSFORM : public API_SGNODE
{
public:
API_TRANSFORM( SGNODE* aParent );
bool GetLocalTransforms( SGNODE** aNodeList, int& nListItems );
bool GetOtherTransforms( SGNODE** aNodeList, int& nListItems );
bool AddOtherTransform( SGNODE* aTransformNode );
bool GetLocalShapes( SGNODE** aNodeList, int& nListItems );
bool GetOtherShapes( SGNODE** aNodeList, int& nListItems );
bool AddOtherShape( SGNODE* aTransformNode );
bool GetTranslation( SGPOINT& aPoint ) const;
bool GetRotation( SGVECTOR& aVector, double& aAngle ) const;
bool GetScale( SGPOINT& aScale ) const;
bool SetTranslation( const SGPOINT& aPoint );
bool SetRotation( const SGVECTOR& aVector, double aAngle );
bool SetScale( const SGPOINT& aScale );
};
// Appearance and operations
class API_APPEARANCE : public API_SGNODE
{
public:
API_APPEARANCE( SGNODE *aParent );
bool SetEmissive( float aRVal, float aGVal, float aBVal );
bool SetEmissive( const SGCOLOR* aRGBColor );
bool SetEmissive( const SGCOLOR& aRGBColor );
bool SetDiffuse( float aRVal, float aGVal, float aBVal );
bool SetDiffuse( const SGCOLOR* aRGBColor );
bool SetDiffuse( const SGCOLOR& aRGBColor );
bool SetSpecular( float aRVal, float aGVal, float aBVal );
bool SetSpecular( const SGCOLOR* aRGBColor );
bool SetSpecular( const SGCOLOR& aRGBColor );
bool SetAmbient( double aVal );
bool SetShininess( double aVal );
bool SetTransparency( double aVal );
bool GetEmissive( SGCOLOR& aRGBColor );
bool GetDiffuse( SGCOLOR& aRGBColor );
bool GetSpecular( SGCOLOR& aRGBColor );
bool GetAmbient( double& aVal );
bool GetShininess( double& aVal );
bool GetTransparency( double& aVal );
};
// XXX - Color Index and operations
// XXX - Colors and operations
// XXX - Coordinate Index and operations
// XXX - Coordinates and operations
// XXX - Face Set and operations
// XXX - Face Set Index (base class for other indices) and operations
// XXX - Normals Index and operations
// XXX - Normals and operations
// XXX - Shape and operations
};
#endif // SG_API_H

View File

@ -30,8 +30,17 @@
#ifndef SG_BASE_H
#define SG_BASE_H
#include "import_export.h"
class SGCOLOR
#ifndef SGLIB_API
#if defined (COMPILE_SGLIB)
#define SGLIB_API APIEXPORT
#else
#define SGLIB_API APIIMPORT
#endif
#endif
class SGLIB_API SGCOLOR
{
protected:
float red;
@ -55,7 +64,7 @@ private:
};
class SGPOINT
class SGLIB_API SGPOINT
{
public:
double x;
@ -75,7 +84,7 @@ public:
};
class SGVECTOR
class SGLIB_API SGVECTOR
{
private:
void normalize( void );

View File

@ -9,7 +9,7 @@ endif()
project( kicad )
cmake_minimum_required( VERSION 2.8.4 FATAL_ERROR )
cmake_minimum_required( VERSION 2.8.12 FATAL_ERROR )
# because of http://public.kitware.com/Bug/view.php?id=10395
# Path to local CMake modules.
@ -75,6 +75,34 @@ option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON )
set( KICAD_REPO_NAME "product" CACHE STRING "Name of the tree from which this build came." )
# Global setting: exports are explicit
set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )
set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
# Global setting: build everything position independent
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
# CMP0063: CMake < 3.3 does not handle hidden visibility for static libraries,
# and 3.3 is backwards compatible when the minimum version is smaller than 3.3.
if( POLICY CMP0063 )
cmake_policy( GET CMP0063 VISIBILITY_POLICY )
if( VISIBILITY_POLICY STREQUAL NEW )
message( WARNING "Compatibility code for CMake < 3.3 can be removed, search for CMP0063" )
else()
cmake_policy( GET CMP0063 NEW )
endif()
else()
if( CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY AND NOT APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY}hidden" )
endif()
if( CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN AND NOT APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}" )
endif()
endif()
# All CMake downloads go here. Suggested is up in the source tree, not in the build dir where they
# would have to be downloaded over and over again. The default is to choose a directory that is
# hidden on linux (starts with a '.') because there is a way to exclude this directory when grepping
@ -152,14 +180,6 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG" )
if( GXX_HAS_VISIBILITY_FLAG AND NOT APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden" )
endif()
if( GXX_HAS_VISIBILITY_INLINES_FLAG AND NOT APPLE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" )
endif()
find_package( OpenMP QUIET )
if( OPENMP_FOUND )
@ -210,15 +230,6 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
else()
# We build DLL/DSOs from static libraries, so create position independent
# code for all cases, since we do not have DLL/DSO specific static
# libraries. Subdirectories via add_subdirectores() reference this
# variable, and it is either set or empty, empty for Windows.
set( PIC_FLAG -fPIC )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PIC_FLAG}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PIC_FLAG}" )
if( NOT APPLE )
# Thou shalt not link vaporware and tell us it's a valid DSO (apple ld doesn't support it)
set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" )

View File

@ -47,8 +47,6 @@ macro( perform_feature_checks )
include( CheckCXXSourceCompiles )
include( CheckCXXCompilerFlag )
check_cxx_compiler_flag( -fvisibility=hidden GXX_HAS_VISIBILITY_FLAG )
check_cxx_compiler_flag( -fvisibility-inlines-hidden GXX_HAS_VISIBILITY_INLINES_FLAG )
check_include_file( "malloc.h" HAVE_MALLOC_H )

View File

@ -132,8 +132,6 @@ else()
set( bootstrap ./bootstrap.sh --with-libraries=${libs_csv} )
# pass to *both* C and C++ compilers
set( BOOST_CFLAGS "cflags=${PIC_FLAG}" )
set( BOOST_CXXFLAGS "cxxflags=${PIC_FLAG}" )
set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
unset( b2_libs )
endif()

View File

@ -2,7 +2,7 @@ Contribute to KiCad (under Linux)
--------------------
1) make sure you have all the dependencies of KiCad:
sudo apt-get install debhelper dpatch libx11-dev
sudo apt-get install debhelper dpatch libx11-dev libglm-dev
sudo apt-get install libglu1-mesa-dev libgl1-mesa-dev mesa-common-dev
sudo apt-get install libwxbase2.8-dev libwxgtk2.8-dev libboost-dev fakeroot
sudo apt-get install cmake bzr

View File

@ -91,6 +91,11 @@ date and contain the latest security fixes.
The [OpenGL Extension Wrangler][GLEW] is an OpenGL helper library used by the KiCad graphics
abstraction library [GAL] and is always required to build KiCad.
## GLM OpenGL Mathematics Library ## {#glm}
The [OpenGL Mathematics Library][GLM] is an OpenGL helper library used by the KiCad graphics
abstraction library [GAL] and is always required to build KiCad.
## GLUT OpenGL Utility Toolkit Library ## {#glut}
The [OpenGL Utility Toolkit][GLUT] is an OpenGL helper library used by the KiCad graphics

View File

@ -260,7 +260,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
GetScreen()->SetFileName( fullFileName );
g_RootSheet->SetFileName( fullFileName );
g_RootSheet->SetName( "root" );
SetStatusText( wxEmptyString );
ClearMsgPanel();

View File

@ -98,6 +98,11 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
else
{
item = LocateAndShowItem( aPosition );
// Show the sheet information when the user clicks anywhere there are no items
// in the schematic.
if( item == NULL )
SetMsgPanel( GetCurrentSheet().Last() );
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.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
@ -204,7 +204,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
&m_pos.x, &m_pos.y, &m_size.x, &m_size.y ) != 4 )
|| ( ((char*)aLine)[0] != 'S' ) )
{
aErrorMsg.Printf( wxT( " ** Eeschema file sheet struct error at line %d, aborted\n" ),
aErrorMsg.Printf( wxT( " ** Eeschema file sheet error at line %d, aborted\n" ),
aLine.LineNumber() );
aErrorMsg << FROM_UTF8( ((char*)aLine) );
@ -301,7 +301,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 )
{
aErrorMsg.Printf( wxT( "**Eeschema file end_sheet struct error at line %d, aborted\n" ),
aErrorMsg.Printf( wxT( "**Eeschema file end_sheet error at line %d, aborted\n" ),
aLine.LineNumber() );
aErrorMsg << FROM_UTF8( ((char*)aLine) );
return false;
@ -474,9 +474,6 @@ int SCH_SHEET::GetMinHeight() const
}
/**
* Delete sheet labels which do not have corresponding hierarchical label.
*/
void SCH_SHEET::CleanupSheet()
{
SCH_SHEET_PINS::iterator i = m_pins.begin();
@ -721,44 +718,15 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
}
bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList )
{
if( m_screen )
{
aList->Push( this );
if( m_screen == aScreen )
return true;
EDA_ITEM* strct = m_screen->GetDrawItems();
while( strct )
{
if( strct->Type() == SCH_SHEET_T )
{
SCH_SHEET* ss = (SCH_SHEET*) strct;
if( ss->LocatePathOfScreen( aScreen, aList ) )
return true;
}
strct = strct->Next();
}
aList->Pop();
}
return false;
}
bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
{
bool success = true;
SCH_SCREEN* screen = NULL;
if( !m_screen )
{
g_RootSheet->SearchHierarchy( m_fileName, &screen );
GetRootSheet()->SearchHierarchy( m_fileName, &screen );
if( screen )
{
@ -782,6 +750,11 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
{
SCH_SHEET* sheetstruct = (SCH_SHEET*) bs;
// Set the parent to this sheet. This effectively creates the
// schematic sheet hierarchy eliminating the need to keep a
// copy of the root sheet in order to generate the hierarchy.
sheetstruct->SetParent( this );
if( !sheetstruct->Load( aFrame ) )
success = false;
}
@ -813,6 +786,7 @@ int SCH_SHEET::CountSheets()
}
}
}
return count;
}
@ -827,11 +801,10 @@ void SCH_SHEET::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
{
aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Path" ), GetHumanReadablePath(), DARKMAGENTA ) );
#if 0 // Set to 1 to display the sheet time stamp (mainly for test)
wxString msg;
msg.Printf( wxT( "%.8X" ), m_TimeStamp );
aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), msg, BLUE ) );
#if 1 // Set to 1 to display the sheet time stamp (mainly for test)
aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), GetPath(), BLUE ) );
#endif
}
@ -1148,7 +1121,6 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
Text = m_name;
size = wxSize( m_sheetNameSize, m_sheetNameSize );
//pos = m_pos; pos.y -= 4;
thickness = GetDefaultLineThickness();
thickness = Clamp_Text_PenSize( thickness, size, false );
@ -1181,6 +1153,67 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
}
SCH_SHEET* SCH_SHEET::GetRootSheet()
{
EDA_ITEM* parent = GetParent();
SCH_SHEET* rootSheet = this;
while( parent )
{
// The parent of a SCH_SHEET object can only be another SCH_SHEET object or NULL.
wxASSERT_MSG( parent->Type() == SCH_SHEET_T, "SCH_SHEET parent is not a SCH_SHEET" );
rootSheet = static_cast<SCH_SHEET*>( parent );
parent = parent->GetParent();
}
return rootSheet;
}
void SCH_SHEET::GetPath( SCH_CONST_SHEETS& aSheetPath ) const
{
aSheetPath.insert( aSheetPath.begin(), const_cast<SCH_SHEET*>( this ) );
if( GetParent() )
static_cast<SCH_SHEET*>( GetParent() )->GetPath( aSheetPath );
}
wxString SCH_SHEET::GetPath() const
{
wxString tmp;
wxString path = "/";
const SCH_SHEET* sheet = this;
while( sheet->GetParent() )
{
tmp.Printf( "/%8.8lX", (long unsigned) sheet->GetTimeStamp() );
// We are walking up the parent stack so prepend each time stamp.
path = tmp + path;
sheet = static_cast<SCH_SHEET*>( sheet->GetParent() );
}
return path;
}
wxString SCH_SHEET::GetHumanReadablePath() const
{
wxString path = "/";
const SCH_SHEET* sheet = this;
while( sheet->GetParent() )
{
// We are walking up the parent stack so prepend each sheet name.
path = "/" + sheet->GetName() + path;
sheet = static_cast<SCH_SHEET*>( sheet->GetParent() );
}
return path;
}
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
{
wxLogDebug( wxT( "Sheet assignment operator." ) );
@ -1214,6 +1247,35 @@ SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
}
bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const
{
// Don't waste time against comparing the same objects..
if( this == &aRhs )
return false;
SCH_CONST_SHEETS lhsPath, rhsPath;
GetPath( lhsPath );
aRhs.GetPath( rhsPath );
// Shorter paths are less than longer paths.
if( lhsPath.size() < rhsPath.size() )
return true;
if( lhsPath.size() > rhsPath.size() )
return false;
// Compare time stamps when path lengths are the same.
for( unsigned i = 0; i < lhsPath.size(); i++ )
{
if( lhsPath[i]->GetTimeStamp() < rhsPath[i]->GetTimeStamp() )
return true;
}
return false;
}
#if defined(DEBUG)
void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const

View File

@ -265,7 +265,7 @@ public:
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* Usually return true for small items (labels, junctions) and false for
* items which can be large (hierarchical sheets, compoments)
* items which can be large (hierarchical sheets, components)
* @return false for a hierarchical sheet
*/
bool IsMovableFromAnchorPoint() { return false; }
@ -457,19 +457,6 @@ public:
*/
bool SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen );
/**
* Function LocatePathOfScreen
* search the existing hierarchy for an instance of screen "FileName".
* don't bother looking at the root sheet - it must be unique,
* no other references to its m_screen otherwise there would be
* loops in the hierarchy.
*
* @param aScreen = the SCH_SCREEN* screen that we search for
* @param aList = the SCH_SHEET_PATH* that must be used
* @return true if found
*/
bool LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList );
/**
* Function CountSheets
* calculates the number of sheets found in "this"
@ -490,7 +477,7 @@ public:
{
m_fileName = aFilename;
// Filenames are stored using unix notation
m_fileName.Replace( wxT("\\"), wxT("/") );
m_fileName.Replace( wxT( "\\" ), wxT( "/" ) );
}
bool ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName );
@ -555,7 +542,7 @@ public:
void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const;
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] );
const KICAD_T scanTypes[] );
wxString GetSelectMenuText() const;
@ -566,6 +553,21 @@ public:
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
/**
* Operator <
*
* test if a \a aRhs is less than this sheet.
*
* Sheet comparison order is:
* The number of parent sheets of this sheet is less than \a aRhs.
* When the number of parent sheets for this sheet are the same as \a aRhs, the time
* stamps of each parent sheet are compared from the root sheet to the last sheet.
*
* @param aRhs is an SCH_SHEET reference to the right hand side of the comparison.
* @return true if this #SCH_SHEET is less than \a aRhs.
*/
bool operator<( const SCH_SHEET& aRhs ) const;
wxPoint GetPosition() const { return m_pos; }
void SetPosition( const wxPoint& aPosition );
@ -578,6 +580,59 @@ public:
EDA_ITEM* Clone() const;
/**
* Function GetRootSheet
*
* returns the root sheet of this SCH_SHEET object.
*
* The root (top level) sheet can be found by walking up the parent links until the only
* sheet that has no parent is found. The root sheet can be found from any sheet in the
* hierarchy.
*
* @return a SCH_SHEET pointer to the root sheet.
*/
SCH_SHEET* GetRootSheet();
/**
* Function IsRootSheet
*
* returns true if `this` sheet has no parent which indicates it is the root (top level)
* sheet.
*
* @return true if this is the root sheet, otherwise false.
*/
bool IsRootSheet() const { return GetParent() == NULL; }
/**
* Function GetPath
*
* recurses up the parent branch up to the root sheet adding a pointer for each
* parent sheet to \a aSheetPath.
*
* @param aSheetPath is a refernce to an #SCH_SHEETS object to populate.
*/
void GetPath( std::vector<const SCH_SHEET*>& aSheetPath ) const;
/**
* Function GetPath
*
* returns a wxString containing the sheet path of this SCH_SHEET.
*
* The SCH_SHEET path is a Posix like path containing the hexadecimal time stamps in
* the parent order of this SCH_SHEET. It looks something like /4567FEDC/AA2233DD/.
*/
wxString GetPath() const;
/**
* Function GetHumanReadablePath
*
* returns a wxString containing the human readable path of this sheet.
*
* Human readable SCH_SHEET paths are Posix like paths made up of the sheet names
* in the parent order of this SCH_SHEET. It looks something like /sheet1/sheet2.
*/
wxString GetHumanReadablePath() const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // override
#endif
@ -595,6 +650,9 @@ protected:
};
typedef std::vector< SCH_SHEET* > SCH_SHEETS;
typedef std::vector< SCH_SHEET* > SCH_SHEETS;
typedef std::vector< const SCH_SHEET* > SCH_CONST_SHEETS;
typedef SCH_SHEETS::iterator SCH_SHEETS_ITER;
typedef SCH_SHEETS::const_iterator SCH_SHEETS_CITER;
#endif /* SCH_SHEEET_H */

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.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
@ -519,6 +519,8 @@ void SCH_EDIT_FRAME::CreateScreens()
if( g_RootSheet == NULL )
{
g_RootSheet = new SCH_SHEET();
g_RootSheet->SetName( "root" );
g_RootSheet->SetFileName( "noname.sch" );
}
if( g_RootSheet->GetScreen() == NULL )

View File

@ -677,14 +677,18 @@ void DIALOG_PLOT::applyPlotSettings()
tempOptions.SetGerberPrecision( m_rbGerberFormat->GetSelection() == 0 ? 5 : 6 );
LSET selectedLayers;
for( unsigned i = 0; i < m_layerList.size(); i++ )
{
if( m_layerCheckListBox->IsChecked( i ) )
selectedLayers.set( m_layerList[i] );
}
// Get a list of copper layers that aren't being used by inverting enabled layers.
LSET disabledCopperLayers = LSET::AllCuMask() & ~m_board->GetEnabledLayers();
// Enable all of the disabled copper layers.
// If someone enables more copper layers they will be selected by default.
selectedLayers = selectedLayers | disabledCopperLayers;
tempOptions.SetLayerSelection( selectedLayers );
tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
@ -782,7 +786,16 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
for( LSEQ seq = m_plotOpts.GetLayerSelection().UIOrder(); seq; ++seq )
{
LAYER_ID layer = *seq;
// All copper layers that are disabled are actually selected
// This is due to wonkyness in automatically selecting copper layers
// for plotting when adding more than two layers to a board.
// If plot options become accessible to the layers setup dialog
// please move this functionality there!
// This skips a copper layer if it is actually disabled on the board.
if( ( LSET::AllCuMask() & ~m_board->GetEnabledLayers() )[layer] )
continue;
// Pick the basename from the board file
wxFileName fn( boardFilename );

View File

@ -79,8 +79,7 @@ static bool setInt( int* aInt, int aValue, int aMin, int aMax )
// PCB_PLOT_PARAMS
PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() :
m_layerSelection( 4, B_Cu, F_Cu, F_SilkS, B_SilkS )
PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
{
m_useGerberProtelExtensions = false;
m_useGerberAttributes = false;
@ -116,6 +115,7 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() :
m_referenceColor = BLACK;
m_valueColor = BLACK;
m_textMode = PLOTTEXTMODE_DEFAULT;
m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask();
// This parameter controls if the NPTH pads will be plotted or not
// it is a "local" parameter
@ -377,7 +377,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
*/
// sorry, use the UI once to fix:
aPcbPlotParams->m_layerSelection = LSET( 4, B_Cu, F_Cu, F_SilkS, B_SilkS );
aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask();
}
else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
{

View File

@ -128,8 +128,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
if( success && ( aZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
{
DisplayError( this,
_( "The duplicated zone is on the same layer as the initial zone, which has no sense.\n"
"Please, choose an other layer for the new zone") );
_( "The duplicated zone cannot be on the same layer as the original zone." ) );
success = false;
}
@ -158,8 +157,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
if( GetBoard()->GetAreaIndex( newZone ) >= 0
&& GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( newZone, true ) )
{
DisplayError( this,
_( "The outline of the duplicated zone fails DRC check!" ) );
DisplayInfoMessage( this, _( "Warning: The new zone fails DRC" ) );
}
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );

View File

@ -112,6 +112,7 @@ install_prerequisites()
libbz2-dev
libcairo2-dev
libglew-dev
libglm-dev
libssl-dev
libwxgtk3.0-dev
"
@ -152,6 +153,7 @@ install_prerequisites()
doxygen
cairo-devel
glew-devel
glm
grep
openssl-devel
wxGTK3-devel