diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8c5d6c4efdb32b65425b6679afdfee6e2f80c1b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,88 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc +*.pyd + +# Binaries +# -------- +*.lib +*.dll +*.exe + +# TopLinker +# ---------------------------------------------------------------------------- + +**/dist/ +**/build/ +!src/lib/*.qm + +# SINCPM +sincpm-lock.json + +# qdoc +qdoc/html/ +*.qch +doc.tags \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ee6a43eea605366cb3b2db49122e3e45f95060f..13559a826e630016e63afb4b8f94e07d88a4ad42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.1) -cmake_policy(VERSION 3.1) +cmake_minimum_required(VERSION 3.16) +cmake_policy(VERSION 3.16) # Enable policy to not use RPATH settings for install_name on macOS. if(POLICY CMP0068) @@ -15,12 +15,17 @@ endif() project(pcbcam LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -find_package(Qt5 5.12 REQUIRED COMPONENTS Core Gui Widgets) +# find_package(Qt6 6.2.1 REQUIRED COMPONENTS Core Gui Widgets Qml) +find_package(Qt6 COMPONENTS Core REQUIRED) +find_package(Qt6 COMPONENTS Gui REQUIRED) +find_package(Qt6 COMPONENTS Widgets REQUIRED) +find_package(Qt6 COMPONENTS Qml REQUIRED) +find_package(Qt6 COMPONENTS Network REQUIRED) # ================================ General configuration ====================================== # Set CPP standard to C++11 minimum. -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) # The library for which we will create bindings. You can change the name to something # relevant for your project. @@ -41,64 +46,72 @@ set(typesystem_file ${CMAKE_SOURCE_DIR}/bindings.xml) # Specify which C++ files will be generated by shiboken. This includes the module wrapper # and a '.cpp' file per C++ type. These are needed for generating the module shared # library. +set(name_space "") set(generated_sources ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcam_module_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamabstractdataio_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamattrdefine_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcam_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcam_attrcompareinfo_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcam_featureselectionfilter_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamconfig_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamcore_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfeature_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfeatureline_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfeaturepad_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfeaturearc_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfeaturetext_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfeaturebarcode_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfeaturesurface_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfont_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamfontcharline_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamjob_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamlayer_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcammath_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcammatrixlayer_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamstep_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsteprepeat_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbol_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolr_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbols_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolrect_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolrectr_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolrectc_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymboloval_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymboldi_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymboloct_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymboldonutr_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymboldonuts_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolhexl_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolhexs_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolbfr_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolbfs_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymboltri_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolovalh_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolthr_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolths_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolsths_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolstho_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolsrths_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolrcths_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolrctho_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolel_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolmoire_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymboluser_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamsymbolfactory_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamutil_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamodbfeatureparser_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamodbmatrixparser_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamparserhelper_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcamcanvas_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/pcbcampopviewwindow_wrapper.cpp) + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamabstractdataio_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamattrdefine_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcam_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcam_featureselectionfilter_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcam_attrcompareinfo_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamconfig_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamcore_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeature_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeatureline_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeaturepad_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeaturearc_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeaturetext_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeaturebarcode_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeaturesurface_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeaturepath_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfeaturecomponent_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfont_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamfontcharline_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamjob_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamlayer_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcammath_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcammatrixlayer_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamstep_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsteprepeat_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbol_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolr_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbols_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolrect_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolrectr_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolrectc_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymboloval_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymboldi_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymboloct_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymboldonutr_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymboldonuts_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolhexl_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolhexs_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolbfr_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolbfs_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymboltri_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolovalh_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolthr_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolths_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolsths_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolstho_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolsrths_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolrcths_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolrctho_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolel_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolmoire_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymboluser_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamsymbolfactory_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamutil_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamdrillparser_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamgerber274xparser_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamodbcomponentparser_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamodbedadataparser_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamodbfeatureinfo_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamodbfeatureparser_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamodbmatrixparser_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamparserhelper_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcamcanvas_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${bindings_library}/${name_space}pcbcampopviewwindow_wrapper.cpp) # ================================== Shiboken detection ====================================== @@ -109,8 +122,8 @@ endif() message(STATUS "Using python interpreter: ${python_interpreter}") # Macro to get various pyside / python include / link flags and paths. -# Uses the not entirely supported utils/pyside2_config.py file. -macro(pyside2_config option output_var) +# Uses the not entirely supported utils/pyside_config.py file. +macro(pyside_config option output_var) if(${ARGC} GREATER 2) set(is_list ${ARGV2}) else() @@ -118,13 +131,13 @@ macro(pyside2_config option output_var) endif() execute_process( - COMMAND ${python_interpreter} "${CMAKE_SOURCE_DIR}/pyside2_config.py" + COMMAND ${python_interpreter} "${CMAKE_SOURCE_DIR}/pyside_config.py" ${option} OUTPUT_VARIABLE ${output_var} OUTPUT_STRIP_TRAILING_WHITESPACE) if ("${${output_var}}" STREQUAL "") - message(FATAL_ERROR "Error: Calling pyside2_config.py ${option} returned no output.") + message(FATAL_ERROR "Error: Calling pyside_config.py ${option} returned no output.") endif() if(is_list) string (REPLACE " " ";" ${output_var} "${${output_var}}") @@ -132,17 +145,17 @@ macro(pyside2_config option output_var) endmacro() # Query for the shiboken generator path, Python path, include paths and linker flags. -pyside2_config(--shiboken2-module-path shiboken2_module_path) -pyside2_config(--shiboken2-generator-path shiboken2_generator_path) -pyside2_config(--pyside2-path pyside2_path) -pyside2_config(--pyside2-include-path pyside2_include_dir 1) -pyside2_config(--python-include-path python_include_dir) -pyside2_config(--shiboken2-generator-include-path shiboken_include_dir 1) -pyside2_config(--shiboken2-module-shared-libraries-cmake shiboken_shared_libraries 0) -pyside2_config(--python-link-flags-cmake python_linking_data 0) -pyside2_config(--pyside2-shared-libraries-cmake pyside2_shared_libraries 0) - -set(shiboken_path "${shiboken2_generator_path}/shiboken2${CMAKE_EXECUTABLE_SUFFIX}") +pyside_config(--shiboken-module-path shiboken_module_path) +pyside_config(--shiboken-generator-path shiboken_generator_path) +pyside_config(--pyside-path pyside_path) +pyside_config(--pyside-include-path pyside_include_dir 1) +pyside_config(--python-include-path python_include_dir) +pyside_config(--shiboken-generator-include-path shiboken_include_dir 1) +pyside_config(--shiboken-module-shared-libraries-cmake shiboken_shared_libraries 0) +pyside_config(--python-link-flags-cmake python_linking_data 0) +pyside_config(--pyside-shared-libraries-cmake pyside_shared_libraries 0) + +set(shiboken_path "${shiboken_generator_path}/shiboken6${CMAKE_EXECUTABLE_SUFFIX}") if(NOT EXISTS ${shiboken_path}) message(FATAL_ERROR "Shiboken executable not found at path: ${shiboken_path}") endif() @@ -158,7 +171,7 @@ endif() # Enable rpaths so that the built shared libraries find their dependencies. set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -set(CMAKE_INSTALL_RPATH ${shiboken2_module_path} ${CMAKE_CURRENT_SOURCE_DIR}) +set(CMAKE_INSTALL_RPATH ${shiboken_module_path} ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # ============================================================================================= # !!! End of dubious section. @@ -169,34 +182,38 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Get all relevant Qt include dirs, to pass them on to shiboken. -get_property(QT_CORE_INCLUDE_DIRS TARGET Qt5::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES) -get_property(QT_GUI_INCLUDE_DIRS TARGET Qt5::Gui PROPERTY INTERFACE_INCLUDE_DIRECTORIES) -get_property(QT_WIDGETS_INCLUDE_DIRS TARGET Qt5::Widgets PROPERTY INTERFACE_INCLUDE_DIRECTORIES) -set(QT_INCLUDE_DIRS ${QT_CORE_INCLUDE_DIRS} ${QT_GUI_INCLUDE_DIRS} ${QT_WIDGETS_INCLUDE_DIRS}) +get_property(QT_CORE_INCLUDE_DIRS TARGET Qt6::Core PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +get_property(QT_GUI_INCLUDE_DIRS TARGET Qt6::Gui PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +get_property(QT_WIDGETS_INCLUDE_DIRS TARGET Qt6::Widgets PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +get_property(QT_QML_INCLUDE_DIRS TARGET Qt6::Qml PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +get_property(QT_NETWORK_INCLUDE_DIRS TARGET Qt6::Network PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +set(QT_INCLUDE_DIRS ${QT_CORE_INCLUDE_DIRS} ${QT_GUI_INCLUDE_DIRS} ${QT_WIDGETS_INCLUDE_DIRS} ${QT_QML_INCLUDE_DIRS} ${QT_NETWORK_INCLUDE_DIRS}) set(INCLUDES "") foreach(INCLUDE_DIR ${QT_INCLUDE_DIRS}) list(APPEND INCLUDES "-I${INCLUDE_DIR}") endforeach() # On macOS, check if Qt is a framework build. This affects how include paths should be handled. -get_target_property(QtCore_is_framework Qt5::Core FRAMEWORK) +get_target_property(QtCore_is_framework Qt6::Core FRAMEWORK) if (QtCore_is_framework) - get_target_property(qt_core_library_location Qt5::Core LOCATION) + get_target_property(qt_core_library_location Qt6::Core LOCATION) get_filename_component(qt_core_library_location_dir "${qt_core_library_location}" DIRECTORY) get_filename_component(lib_dir "${qt_core_library_location_dir}/../" ABSOLUTE) list(APPEND INCLUDES "--framework-include-paths=${lib_dir}") endif() # We need to include the headers for the module bindings that we use. -set(pyside2_additional_includes "") -foreach(INCLUDE_DIR ${pyside2_include_dir}) - list(APPEND pyside2_additional_includes "${INCLUDE_DIR}/QtCore") - list(APPEND pyside2_additional_includes "${INCLUDE_DIR}/QtGui") - list(APPEND pyside2_additional_includes "${INCLUDE_DIR}/QtWidgets") +set(pyside_additional_includes "") +foreach(INCLUDE_DIR ${pyside_include_dir}) + list(APPEND pyside_additional_includes "${INCLUDE_DIR}/QtCore") + list(APPEND pyside_additional_includes "${INCLUDE_DIR}/QtGui") + list(APPEND pyside_additional_includes "${INCLUDE_DIR}/QtWidgets") + list(APPEND pyside_additional_includes "${INCLUDE_DIR}/QtQml") + list(APPEND pyside_additional_includes "${INCLUDE_DIR}/QtNetwork") endforeach() -# Define the wiggly shared library for which we will create bindings. +# Define the shared library for which we will create bindings. set(${project_library}_sources lib/core/abstractdataio.h lib/core/attrdefine.cpp @@ -215,6 +232,10 @@ set(${project_library}_sources lib/core/symbol.cpp lib/core/symbolfactory.cpp lib/core/util.cpp + lib/parser/drillparser.cpp + lib/parser/gerber274xparser.cpp + lib/parser/odbcomponentparser.cpp + lib/parser/odbedadataparser.cpp lib/parser/odbfeatureparser.cpp lib/parser/odbmatrixparser.cpp lib/parser/parserhelper.cpp @@ -224,7 +245,7 @@ add_library(${project_library} SHARED ${${project_library}_sources}) set_property(TARGET ${project_library} PROPERTY PREFIX "") # Needed mostly on Windows to export symbols, and create a .lib file, otherwise the binding -# library can't link to the wiggly library. +# library can't link to the pcbcam library. target_compile_definitions(${project_library} PRIVATE BINDINGS_BUILD) @@ -238,7 +259,7 @@ set(shiboken_options --generator-set=shiboken --enable-parent-ctor-heuristic ${INCLUDES} -I${CMAKE_SOURCE_DIR} -T${CMAKE_SOURCE_DIR} - -T${pyside2_path}/typesystems + -T${pyside_path}/typesystems --output-directory=${CMAKE_CURRENT_BINARY_DIR} ) @@ -265,15 +286,23 @@ add_library(${bindings_library} SHARED ${${bindings_library}_sources}) # Apply relevant include and link flags. -target_include_directories(${bindings_library} PRIVATE ${pyside2_additional_includes}) -target_include_directories(${bindings_library} PRIVATE ${pyside2_include_dir}) +target_include_directories(${bindings_library} PRIVATE ${pyside_additional_includes}) +target_include_directories(${bindings_library} PRIVATE ${pyside_include_dir}) target_include_directories(${bindings_library} PRIVATE ${python_include_dir}) target_include_directories(${bindings_library} PRIVATE ${shiboken_include_dir}) -target_link_libraries(${project_library} PRIVATE Qt5::Widgets) -target_link_libraries(${bindings_library} PRIVATE Qt5::Widgets) +target_link_libraries(${project_library} PRIVATE Qt6::Core) +target_link_libraries(${bindings_library} PRIVATE Qt6::Core) +target_link_libraries(${project_library} PRIVATE Qt6::Gui) +target_link_libraries(${bindings_library} PRIVATE Qt6::Gui) +target_link_libraries(${project_library} PRIVATE Qt6::Widgets) +target_link_libraries(${bindings_library} PRIVATE Qt6::Widgets) +target_link_libraries(${project_library} PRIVATE Qt6::Qml) +target_link_libraries(${bindings_library} PRIVATE Qt6::Qml) +target_link_libraries(${project_library} PRIVATE Qt6::Network) +target_link_libraries(${bindings_library} PRIVATE Qt6::Network) target_link_libraries(${bindings_library} PRIVATE ${project_library}) -target_link_libraries(${bindings_library} PRIVATE ${pyside2_shared_libraries}) +target_link_libraries(${bindings_library} PRIVATE ${pyside_shared_libraries}) target_link_libraries(${bindings_library} PRIVATE ${shiboken_shared_libraries}) # Adjust the name of generated module. @@ -312,7 +341,7 @@ if(WIN32) # Circumvent some "#pragma comment(lib)"s in "include/pyconfig.h" which might force to link # against a wrong python shared library. - set(python_versions_list 3 32 33 34 35 36 37 38) + set(python_versions_list 3 36 37 38 39) set(python_additional_link_flags "") foreach(ver ${python_versions_list}) set(python_additional_link_flags @@ -325,7 +354,7 @@ if(WIN32) PROPERTIES LINK_FLAGS "${python_additional_link_flags}") # Compile a list of shiboken shared libraries to be installed, so that - # the user doesn't have to set the PATH manually to point to the PySide2 package. + # the user doesn't have to set the PATH manually to point to the PySide package. foreach(library_path ${shiboken_shared_libraries}) string(REGEX REPLACE ".lib$" ".dll" library_path ${library_path}) file(TO_CMAKE_PATH ${library_path} library_path) diff --git a/bindings.h b/bindings.h index 9db07c766fecbbb000427d36825927a183c6f3f6..84c08c2d80c25e30d6f3ce905b4d919cf2d27732 100644 --- a/bindings.h +++ b/bindings.h @@ -17,6 +17,10 @@ #include "lib/core/symbol.h" #include "lib/core/symbolfactory.h" #include "lib/core/util.h" +#include "lib/parser/drillparser.h" +#include "lib/parser/gerber274xparser.h" +#include "lib/parser/odbcomponentparser.h" +#include "lib/parser/odbedadataparser.h" #include "lib/parser/odbfeatureparser.h" #include "lib/parser/odbmatrixparser.h" #include "lib/parser/parserhelper.h" diff --git a/bindings.xml b/bindings.xml index a160b80d5df2321400abf6c3a38e9cb2aabf39aa..ce15616c27bc60d95d6aa7dcb2c922a126b04112 100644 --- a/bindings.xml +++ b/bindings.xml @@ -4,6 +4,10 @@ <load-typesystem name="typesystem_core.xml" generate="no"/> <load-typesystem name="typesystem_gui.xml" generate="no"/> <load-typesystem name="typesystem_widgets.xml" generate="no"/> + <load-typesystem name="typesystem_qml.xml" generate="no"/> + <load-typesystem name="typesystem_network.xml" generate="no"/> + + <!-- <namespace-type name="titan"> --> <!--abstractdataio--> <object-type name="PcbCamAbstractDataIo"/> @@ -27,6 +31,8 @@ <enum-type name="FeatureSelectionOperation"/> <enum-type name="FeatureSelectionMode"/> <enum-type name="UnitsType"/> + <enum-type name="ZerosOmit"/> + <enum-type name="CoordNotation"/> <enum-type name="LogicOperator"/> <enum-type name="SnapMode" flags="SnapModes"/> <enum-type name="DisplayOption" flags="DisplayOptions"/> @@ -35,7 +41,6 @@ <object-type name="AttrCompareInfo"/> </object-type> - <!--config--> <object-type name="PcbCamConfig"/> @@ -50,6 +55,8 @@ <object-type name="PcbCamFeatureText"/> <object-type name="PcbCamFeatureBarcode"/> <object-type name="PcbCamFeatureSurface"/> + <object-type name="PcbCamFeaturePath"/> + <object-type name="PcbCamFeatureComponent"/> <!--font--> <object-type name="PcbCamFont"/> @@ -110,11 +117,32 @@ <object-type name="PcbCamSymbolFactory"/> <!--util--> - <rejection class="PcbCamUtil" function-name="point2segDist"/> - <rejection class="PcbCamUtil" function-name="point2polylineDist"/> + <!-- <rejection class="PcbCamUtil" function-name="point2segDist"/> --> + <!-- <rejection class="PcbCamUtil" function-name="point2polylineDist"/> --> + <object-type name="PcbCamUtil"/> + <!-- <rejection class="*" function-name="calcPathArc"/> --> + + <!--drillparser--> + <object-type name="PcbCamDrillParser"> + <enum-type name="DrillFormat"/> + <!-- <object-type name="DrillStatement"/> --> + </object-type> + + <!--gerber274xparser--> + <object-type name="PcbCamGerber274XParser"> + <enum-type name="Cmd"/> + <!-- <object-type name="ApertureInfo"/> --> + </object-type> + + <!--odbcomponentparser--> + <object-type name="PcbCamOdbComponentParser"/> + + <!--odbedadataparser--> + <object-type name="PcbCamOdbEdaDataParser"/> <!--odbfeatureparser--> + <object-type name="PcbCamOdbFeatureInfo"/> <object-type name="PcbCamOdbFeatureParser"/> <!--odbmatrixparser--> @@ -131,4 +159,5 @@ <!--popviewwindow--> <object-type name="PcbCamPopViewWindow"/> + <!-- </namespace-type> --> </typesystem> \ No newline at end of file diff --git a/examples/dialog.py b/examples/dialog.py new file mode 100644 index 0000000000000000000000000000000000000000..0d1fa952f6e48ebf708ea2457dbe3f110dee8c95 --- /dev/null +++ b/examples/dialog.py @@ -0,0 +1,23 @@ +from PySide6.QtWidgets import QDialog, QLineEdit, QVBoxLayout + +# Python binding from the C++ widget +from timp.foo import FooWidget as FooWidgetCPP + + + +class Dialog(QDialog): + def __init__(self, parent=None): + super().__init__(parent) + wiggly_widget_cpp = FooWidgetCPP(self) + lineEdit = QLineEdit(self) + + layout = QVBoxLayout(self) + layout.addWidget(wiggly_widget_cpp) + layout.addWidget(lineEdit) + wiggly_widget_cpp.setRunning(True) + + lineEdit.textChanged.connect(wiggly_widget_cpp.setText) + lineEdit.setText("Hello world!") + + self.setWindowTitle("Wiggly") + self.resize(360, 145) diff --git a/examples/main.py b/examples/main.py new file mode 100644 index 0000000000000000000000000000000000000000..89f325017f2ce764bb4ebb6b6891fd33f637d361 --- /dev/null +++ b/examples/main.py @@ -0,0 +1,15 @@ +import sys + +from PySide6.QtWidgets import QApplication +from pcbcam import PcbCamCanvas +from pcbcam import PcbCamUtil as UT + +if __name__ == "__main__": + app = QApplication() + # w = PcbCamCanvas() + # w.show() + a = UT.formatNumber(12.135456789, 2) + print(a) + print(int(PcbCamCanvas.PanViewMode)) + sys.exit(0) + # sys.exit(app.exec()) diff --git a/lib/core/abstractdataio.h b/lib/core/abstractdataio.h index 41e49412b9a6403973d681dc47bcd0cf872e74a0..22230e35632c321a5075835bcbb9509428ecb3d6 100644 --- a/lib/core/abstractdataio.h +++ b/lib/core/abstractdataio.h @@ -3,7 +3,6 @@ #include "../titanpcbcamglobal.h" #include <QObject> -TITAN_BEGIN_NAMESPACE class TITAN_PCBCAM_EXPORT PcbCamAbstractDataIo : public QObject { @@ -14,10 +13,9 @@ public: virtual void clearJobDataCache(const QString &/*iJobPath*/) {} virtual QVariantList getDbList() = 0; virtual QVariantList getJobList(const QString &iDb = "") = 0; - virtual QByteArray readJobData(const QString &iJobPath, const QString &iRealtivePath, QString *oError = nullptr) = 0; - virtual bool writeJobData(const QString &iJobPath, const QString &iRealtivePath, const QByteArray &iData, const QString *oError = nullptr) = 0; + virtual QByteArray readJobData(const QString &iJobPath, const QString &iRealtivePath) = 0; + virtual bool writeJobData(const QString &iJobPath, const QString &iRealtivePath, const QByteArray &iData) = 0; }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_ABSTRACTDATAIO_H diff --git a/lib/core/arcpainterinfo.cpp b/lib/core/arcpainterinfo.cpp deleted file mode 100644 index 2272f88379b43cd95127e2b0155a935662f884ba..0000000000000000000000000000000000000000 --- a/lib/core/arcpainterinfo.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "arcpainterinfo.h" -#include <QtMath> -#include <QDebug> - -TITAN_BEGIN_NAMESPACE - -class PcbCamArcPainterInfoData : public QSharedData -{ -public: - PcbCamArcPainterInfoData() { } - PcbCamArcPainterInfoData(const PcbCamArcPainterInfoData &other): QSharedData(other){ } - ~PcbCamArcPainterInfoData() { } - - QRectF rect; - qreal startAngle {0.0}; - qreal spanAngle {0.0}; -}; - -PcbCamArcPainterInfo::PcbCamArcPainterInfo(qreal xs, qreal ys, qreal xe, qreal ye, qreal xc, qreal yc, bool cw) : d(new PcbCamArcPainterInfoData) -{ - qreal sax = xs - xc, say = ys - yc; - qreal eax = xe - xc, eay = ye - yc; - - qreal r = qSqrt(sax * sax + say * say); - - qreal sa = qAtan2(-say, sax); - qreal ea = qAtan2(-eay, eax); - - if (cw) { - if (ea <= sa) { - ea += 2.0 * M_PI; - } - } - else { - if (sa <= ea) { - sa += 2.0 * M_PI; - } - } - - d->rect = QRectF(xc - r, yc - r, r * 2.0, r * 2.0); - d->startAngle = sa * (180.0 / M_PI) *16; - d->spanAngle = (ea - sa) * (180.0 / M_PI) * 16; - -} - -PcbCamArcPainterInfo::PcbCamArcPainterInfo(const PcbCamArcPainterInfo &rhs) : d(rhs.d) -{ - -} - -PcbCamArcPainterInfo &PcbCamArcPainterInfo::operator=(const PcbCamArcPainterInfo &rhs) -{ - if (this != &rhs) - d.operator=(rhs.d); - return *this; -} - -PcbCamArcPainterInfo::~PcbCamArcPainterInfo() -{ - -} - -QRectF PcbCamArcPainterInfo::rect() const -{ - return d->rect; -} - -qreal PcbCamArcPainterInfo::startAngle() const -{ - return d->startAngle; -} - -qreal PcbCamArcPainterInfo::spanAngle() const -{ - return d->spanAngle; -} - -TITAN_END_NAMESPACE diff --git a/lib/core/arcpainterinfo.h b/lib/core/arcpainterinfo.h deleted file mode 100644 index 487fb288486c60c919184219b881279ba4177d5c..0000000000000000000000000000000000000000 --- a/lib/core/arcpainterinfo.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef TITAN_PCBCAM_ARCPAINTERINFO_H -#define TITAN_PCBCAM_ARCPAINTERINFO_H -#include "titanpcbcamglobal.h" -#include <QSharedDataPointer> -#include <QRectF> - -TITAN_BEGIN_NAMESPACE - -class PcbCamArcPainterInfoData; -class TITAN_PCBCAM_EXPORT PcbCamArcPainterInfo -{ -public: - PcbCamArcPainterInfo(qreal xs, qreal ys, qreal xe, qreal ye, qreal xc, qreal yc, bool cw); - PcbCamArcPainterInfo(const PcbCamArcPainterInfo &); - PcbCamArcPainterInfo &operator=(const PcbCamArcPainterInfo &); - ~PcbCamArcPainterInfo(); - - QRectF rect() const; - qreal startAngle() const; - qreal spanAngle() const; - -private: - QSharedDataPointer<PcbCamArcPainterInfoData> d; -}; - -TITAN_END_NAMESPACE - -#endif // TITAN_PCBCAM_ARCPAINTERINFO_H - diff --git a/lib/core/attrdefine.cpp b/lib/core/attrdefine.cpp index 84855c7116cd6d79ef984f4aa6d393d59b9fc158..6734aa10ea49d37d419ac2f59d1e95570c8643fd 100644 --- a/lib/core/attrdefine.cpp +++ b/lib/core/attrdefine.cpp @@ -1,7 +1,5 @@ #include "attrdefine.h" -TITAN_BEGIN_NAMESPACE - class PcbCamAttrDefineData : public QSharedData { public: @@ -244,5 +242,3 @@ PcbCamAttrDefine::Entity PcbCamAttrDefine::entityFromString(const QString &iStr) return entity; } - -TITAN_END_NAMESPACE diff --git a/lib/core/attrdefine.h b/lib/core/attrdefine.h index 98a9fe6229b871417f2b19920db7b4e8c4f75088..e31dcf522097c30685d71d76835500a529f7e923 100644 --- a/lib/core/attrdefine.h +++ b/lib/core/attrdefine.h @@ -5,7 +5,6 @@ #include <QStringList> #include <QVariant> -TITAN_BEGIN_NAMESPACE class PcbCamAttrDefineData; class TITAN_PCBCAM_EXPORT PcbCamAttrDefine @@ -84,9 +83,7 @@ private: QSharedDataPointer<PcbCamAttrDefineData> d; }; -TITAN_END_NAMESPACE - -Q_DECLARE_OPERATORS_FOR_FLAGS(titan::PcbCamAttrDefine::Entity) +Q_DECLARE_OPERATORS_FOR_FLAGS(PcbCamAttrDefine::Entity) #endif // TITAN_PCBCAM_ATTRDEFINE_H diff --git a/lib/core/common.h b/lib/core/common.h index 360212913ce87e2ee4aca2ec42899f30ea70b1b5..14a02568ca910a43a1e7cdcde374a6400144c83f 100644 --- a/lib/core/common.h +++ b/lib/core/common.h @@ -5,8 +5,6 @@ #include <QString> #include <QRegularExpression> -TITAN_BEGIN_NAMESPACE - class TITAN_PCBCAM_EXPORT PcbCam : public QObject { Q_OBJECT @@ -202,8 +200,8 @@ public: ushort type {0}; //比较类型(0:æ˜¯å¦æœ‰æ¤å±žæ€§; 1:属性值是å¦ç›¸ç‰; 2:数值是å¦åœ¨èŒƒå›´) QString name; QString strValue; - double minValue = INTMAX_MIN; - double maxValue = INTMAX_MAX; + double minValue = static_cast<double>(INTMAX_MIN); + double maxValue = static_cast<double>(INTMAX_MAX); AttrCompareInfo() {} AttrCompareInfo(const QString &iAttrStr) { auto idx = iAttrStr.indexOf("="); @@ -231,7 +229,6 @@ public: }; }; -TITAN_END_NAMESPACE #endif //TITAN_PCBCAM_COMMON_H diff --git a/lib/core/config.cpp b/lib/core/config.cpp index 0fb6ad53a73f0f2edde0dff6b1b90b902f002144..0d69c9275c232e60db8fc983a5877b0049072b38 100644 --- a/lib/core/config.cpp +++ b/lib/core/config.cpp @@ -1,8 +1,6 @@ #include "config.h" -TITAN_BEGIN_NAMESPACE - class PcbCamConfigData : public QSharedData { public: @@ -60,4 +58,3 @@ void PcbCamConfig::setTarCmd(const QString &iCmd) d->tarCmd = iCmd; } -TITAN_END_NAMESPACE diff --git a/lib/core/config.h b/lib/core/config.h index 4da7a726384937785b1e05c1e92a9202e6ae819d..5ed22fcc272d7b21c20761e25da30e30180bcf48 100644 --- a/lib/core/config.h +++ b/lib/core/config.h @@ -3,7 +3,6 @@ #include "../titanpcbcamglobal.h" #include <QSharedDataPointer> -TITAN_BEGIN_NAMESPACE class PcbCamConfigData; class TITAN_PCBCAM_EXPORT PcbCamConfig @@ -25,6 +24,5 @@ private: QSharedDataPointer<PcbCamConfigData> d; }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_CONFIG_H diff --git a/lib/core/core.cpp b/lib/core/core.cpp index 14a694142e032083f598485b3d1d9bd0c2e919ed..0574a587c0136732fd7b417cc97099a85f852760 100644 --- a/lib/core/core.cpp +++ b/lib/core/core.cpp @@ -2,8 +2,6 @@ #include <QFile> #include <QDir> -TITAN_BEGIN_NAMESPACE - class PcbCamCorePrivate { @@ -66,4 +64,3 @@ PcbCamCore::~PcbCamCore() } -TITAN_END_NAMESPACE diff --git a/lib/core/core.h b/lib/core/core.h index 82c5e815e3af99227716a747484c896e49442cb6..ffb1c3a2fe83e90ba72ddbecb9127fae32c1dc40 100644 --- a/lib/core/core.h +++ b/lib/core/core.h @@ -7,7 +7,6 @@ #include "./abstractdataio.h" #include "./config.h" -TITAN_BEGIN_NAMESPACE class PcbCamCorePrivate; class TITAN_PCBCAM_EXPORT PcbCamCore : public QObject @@ -42,6 +41,4 @@ private: }; -TITAN_END_NAMESPACE - #endif // TITAN_PCBCAM_CORE_H diff --git a/lib/core/feature.cpp b/lib/core/feature.cpp index 0a95f6e5d585c4c600b7a3aed1565b0d2fbce13a..161ebf77caad68d162af47913643fa26f2742550 100644 --- a/lib/core/feature.cpp +++ b/lib/core/feature.cpp @@ -4,7 +4,6 @@ #include "./util.h" #include "./font.h" -TITAN_BEGIN_NAMESPACE class PcbCamFeaturePrivate { @@ -938,5 +937,3 @@ QRectF PcbCamFeatureComponent::boundingRect() const return PcbCamUtil::matrix(d->pos, QPointF(0, 0), d->rotation, d->mirror).mapRect(symbol()->boundingRect()); } - -TITAN_END_NAMESPACE diff --git a/lib/core/feature.h b/lib/core/feature.h index 7e7863d1c536527bc0de4db5cf8569842be5dd93..1aff4085ae6b9cdd33334ef084a79d04490dd462 100644 --- a/lib/core/feature.h +++ b/lib/core/feature.h @@ -9,8 +9,6 @@ #include "./common.h" #include "./font.h" -TITAN_BEGIN_NAMESPACE - class PcbCamSymbol; class PcbCamFeaturePrivate; @@ -269,6 +267,5 @@ private: Q_DISABLE_COPY(PcbCamFeatureComponent) }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_FEATURE_H diff --git a/lib/core/font.cpp b/lib/core/font.cpp index 2f53de822a438d82e3c70dd5afb8f95c4db7eaf7..4435fc524c00b73edc26a69bcf30d1b22cf00294 100644 --- a/lib/core/font.cpp +++ b/lib/core/font.cpp @@ -1,6 +1,5 @@ #include "font.h" -TITAN_BEGIN_NAMESPACE class PcbCamFontData : public QSharedData { @@ -95,4 +94,3 @@ void PcbCamFont::setCharLines(QChar iChar, const QList<PcbCamFontCharLine> &iLin d->charLinesMap.insert(iChar, iLines); } -TITAN_END_NAMESPACE diff --git a/lib/core/font.h b/lib/core/font.h index 5ae12b0b315635c7a0de80515fe8711e5e54d1a2..56ff115c45acafdd68c2f62223b7b827c81aad80 100644 --- a/lib/core/font.h +++ b/lib/core/font.h @@ -5,7 +5,6 @@ #include "./common.h" #include "./fontcharline.h" -TITAN_BEGIN_NAMESPACE class PcbCamFontData; class TITAN_PCBCAM_EXPORT PcbCamFont @@ -36,6 +35,5 @@ private: QSharedDataPointer<PcbCamFontData> d; }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_FONT_H diff --git a/lib/core/fontcharline.cpp b/lib/core/fontcharline.cpp index 5a80e8a247eb111d755a0ec1363e37934e147ee7..9d505ec3788fde5f546b6d3cdf73ff530cd52312 100644 --- a/lib/core/fontcharline.cpp +++ b/lib/core/fontcharline.cpp @@ -1,7 +1,5 @@ #include "fontcharline.h" -TITAN_BEGIN_NAMESPACE - class PcbCamFontCharLineData : public QSharedData { public: @@ -83,4 +81,3 @@ void PcbCamFontCharLine::setWidth(double iWidth) d->width = iWidth; } -TITAN_END_NAMESPACE diff --git a/lib/core/fontcharline.h b/lib/core/fontcharline.h index 95f17ca597bd436b335bf2c7fbd94b5646cea987..9e1589f892468aa4e35f2a05a872847d71f8ff40 100644 --- a/lib/core/fontcharline.h +++ b/lib/core/fontcharline.h @@ -5,7 +5,6 @@ #include <QLineF> #include "./common.h" -TITAN_BEGIN_NAMESPACE class PcbCamFontCharLineData; class TITAN_PCBCAM_EXPORT PcbCamFontCharLine { @@ -36,6 +35,5 @@ private: QSharedDataPointer<PcbCamFontCharLineData> d; }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_FONTCHARLINE_H diff --git a/lib/core/job.cpp b/lib/core/job.cpp index defa5c01933dde7034ef05f437580592269ac151..65026251e05aa9ae529c25f8440a40ce3eb34f16 100644 --- a/lib/core/job.cpp +++ b/lib/core/job.cpp @@ -22,7 +22,6 @@ #include "./config.h" #include "./core.h" -TITAN_BEGIN_NAMESPACE class PcbCamJobPrivate { @@ -255,10 +254,16 @@ PcbCamAttrDefine PcbCamJob::userAttrDefine(const QString &iName) const return d->userAttrDefineMap.value(iName.toLower()); } -QHash<QString, PcbCamAttrDefine> PcbCamJob::userAttrDefine() const +QStringList PcbCamJob::userAttrDefineKeys() const { Q_D(const PcbCamJob); - return d->userAttrDefineMap; + return d->userAttrDefineMap.keys(); +} + +QList<PcbCamAttrDefine> PcbCamJob::userAttrDefineValues() const +{ + Q_D(const PcbCamJob); + return d->userAttrDefineMap.values(); } void PcbCamJob::addUserAttrDefine(const PcbCamAttrDefine &iAttrDefine) @@ -347,7 +352,11 @@ bool PcbCamJob::createLayer(const QString &iLayerName, PcbCam::LayerContext iLay layer.setRow(d->getMaxLayerRow() + 1); layer.setId(d->getMaxLayerId() + 1); d->matrixLayers.append(layer); - emit actionNotified("create_layer", QVariantMap{{"name", iLayerName}, {"context", (int)iLayerContext}, {"type", iLayerType}}); + QVariantMap userData; + userData.insert("name", iLayerName); + userData.insert("context", (int)iLayerContext); + userData.insert("type", iLayerType); + emit actionNotified("create_layer", QVariant::fromValue(userData)); return true; } @@ -398,7 +407,10 @@ bool PcbCamJob::renameLayer(const QString &iOldLayerName, const QString &iNewLay d->layersMap.insert(step + "/" + new_ln, steplayer); } } - emit actionNotified("rename_layer", QVariantMap{{"old_name", iOldLayerName}, {"new_name", iNewLayerName}}); + QVariantMap userData; + userData.insert("old_name", iOldLayerName); + userData.insert("new_name", iNewLayerName); + emit actionNotified("rename_layer", QVariant::fromValue(userData)); return true; } } @@ -743,7 +755,7 @@ void PcbCamJob::loadStepLayer(const QString &iStep, const QString &iLayer) } QString err; - QVariantMap attr = PcbCamParserHelper::parseOdbStructuredText(readJobFile("steps/"+iStep.toLower()+"/layers/"+iLayer.toLower()+"/attrlist"), &err); + QVariantMap attr = PcbCamParserHelper::parseOdbStructuredText(readJobFile("steps/"+iStep.toLower()+"/layers/"+iLayer.toLower()+"/attrlist")); if (!err.isEmpty()) { notifyMessage(err, "ERROR"); } @@ -790,7 +802,7 @@ void PcbCamJob::loadFont(const QString &iFontName) QString err; PcbCamFont *font = new PcbCamFont(); font->setName(iFontName); - if (PcbCamParserHelper::parseOdbFont(fontData, font, &err)) { + if (PcbCamParserHelper::parseOdbFont(fontData, font)) { d->fontsMap.insert(iFontName, font); } else { delete font; @@ -809,7 +821,7 @@ void PcbCamJob::notifyMessage(const QString &iText, const QString &iType, const bool PcbCamJob::readMiscInfo() { QString err; - QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("misc/info"), &err); + QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("misc/info")); if (!err.isEmpty()) { notifyMessage(err, "ERROR"); return false; @@ -828,7 +840,7 @@ bool PcbCamJob::readMiscAttrlist() { Q_D(PcbCamJob); QString err; - QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("misc/attrlist"), &err); + QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("misc/attrlist")); if (!err.isEmpty()) { notifyMessage(err, "ERROR"); return false; @@ -848,7 +860,7 @@ bool PcbCamJob::readMiscUserattr() sysattrfile.open(QFile::ReadOnly | QFile::Text); auto sysattrdata = sysattrfile.readAll(); sysattrfile.close(); - QVariantMap sysdata = PcbCamParserHelper::parseOdbStructuredText(sysattrdata, &err); + QVariantMap sysdata = PcbCamParserHelper::parseOdbStructuredText(sysattrdata); if (!err.isEmpty()) { notifyMessage(err, "ERROR"); } @@ -870,7 +882,7 @@ bool PcbCamJob::readMiscUserattr() } } - QVariantMap userdata = PcbCamParserHelper::parseOdbStructuredText(readJobFile("misc/userattr"), &err); + QVariantMap userdata = PcbCamParserHelper::parseOdbStructuredText(readJobFile("misc/userattr")); if (!err.isEmpty()) { notifyMessage(err, "ERROR"); return false; @@ -901,7 +913,7 @@ bool PcbCamJob::readMatrix() { Q_D(PcbCamJob); QString err; - QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("matrix/matrix"), &err); + QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("matrix/matrix")); if (!err.isEmpty()) { notifyMessage(err, "ERROR"); return false; @@ -962,7 +974,7 @@ bool PcbCamJob::readSteps() QStringList steps = d->matrixSteps.keys(); for (auto stepname : steps) { QString err; - QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("steps/" + stepname + "/stephdr"), &err); + QVariantMap data = PcbCamParserHelper::parseOdbStructuredText(readJobFile("steps/" + stepname + "/stephdr")); if (!err.isEmpty()) { notifyMessage(err, "ERROR"); } @@ -993,7 +1005,7 @@ bool PcbCamJob::readSteps() QPainterPath profile = PcbCamParserHelper::parseOdbProfile(readJobFile("steps/" + stepname + "/profile")); step->setProfile(profile); - QVariantMap stepattr = PcbCamParserHelper::parseOdbStructuredText(readJobFile("steps/" + stepname + "/attrlist"), &err); + QVariantMap stepattr = PcbCamParserHelper::parseOdbStructuredText(readJobFile("steps/" + stepname + "/attrlist")); step->initAttr(stepattr); d->stepsMap.insert(stepname, step); } @@ -1076,7 +1088,7 @@ bool PcbCamJob::importGerber274X(const QString &iGerberFile, const QString &iSte auto apertures = parser.apertures(); QHash<int, QString> dcodeSymbolMap; auto sym_num = d->getMaxConstructSymbolNum(); - for (auto ap : apertures.values()) { + for (auto ap : apertures) { auto sym_name = ap.name; if (!ap.isStandard) { sym_name = QString("construct+%1").arg(++sym_num); @@ -1142,23 +1154,19 @@ bool PcbCamJob::importDrill(const QString &iDrlFile, const QString &iStep, const return true; } -QByteArray PcbCamJob::readJobFile(const QString &iRelPath, QString *oErrStr) const +QByteArray PcbCamJob::readJobFile(const QString &iRelPath) const { Q_D(const PcbCamJob); QString filepath = d->logJobPath + "/" + iRelPath; notifyMessage(QString("read file - %1").arg(filepath), "INFO"); QString err; - auto result = PcbCamCore::instance()->dataIo()->readJobData(this->jobPath(), iRelPath, &err); + auto result = PcbCamCore::instance()->dataIo()->readJobData(this->jobPath(), iRelPath); if (!err.isEmpty()) { notifyMessage(QString("read file -%1 failed! %2").arg(filepath).arg(err), "ERROR"); } - if (oErrStr != nullptr) { - *oErrStr = err; - } return result; } - PcbCamFeature *PcbCamJob::createFeature(const PcbCamOdbFeatureInfo &iFeat) { Q_D(const PcbCamJob); @@ -1246,6 +1254,3 @@ PcbCamFeature *PcbCamJob::createFeature(const PcbCamOdbFeatureInfo &iFeat) } return nullptr; } - - -TITAN_END_NAMESPACE diff --git a/lib/core/job.h b/lib/core/job.h index b9535849534dced887017b7aa7d645e7f20b8753..688e1254837e9aa49819371598aa09ac8cac4463 100644 --- a/lib/core/job.h +++ b/lib/core/job.h @@ -12,19 +12,18 @@ #include "./symbol.h" #include "../parser/odbfeatureparser.h" -TITAN_BEGIN_NAMESPACE class PcbCamJobPrivate; class TITAN_PCBCAM_EXPORT PcbCamJob : public QObject { Q_OBJECT public: - explicit PcbCamJob(QObject *parent = 0); + explicit PcbCamJob(QObject *parent = nullptr); ~PcbCamJob(); signals: void messageNotified(const QString &iMessage, const QString &iType, const QVariant &iUserData) const; - void actionNotified(const QString &iActionName, const QVariantMap &iUserData) const; + void actionNotified(const QString &iActionName, const QVariant &iUserData) const; public slots: QString jobname() const; @@ -53,7 +52,8 @@ public slots: void setJobAttr(const QString &iName, const QVariant &iValue); PcbCamAttrDefine userAttrDefine(const QString &iName) const; - QHash<QString, PcbCamAttrDefine> userAttrDefine() const; + QStringList userAttrDefineKeys() const; + QList<PcbCamAttrDefine> userAttrDefineValues() const; void addUserAttrDefine(const PcbCamAttrDefine &iAttrDefine); PcbCamStep *step(const QString &iStepName) const; @@ -112,7 +112,7 @@ public slots: void notifyMessage(const QString &iText, const QString &iType, const QVariant &iUserData = QVariant()) const; - QByteArray readJobFile(const QString &iRelPath, QString *oErrStr = nullptr) const; + QByteArray readJobFile(const QString &iRelPath) const; bool importGerber274X(const QString &iGerberFile, const QString &iStep, const QString &iLayer); bool importDrill(const QString &iDrlFile, const QString &iStep, const QString &iLayer, const QVariantMap &iStatement); @@ -140,6 +140,4 @@ private: }; -TITAN_END_NAMESPACE - #endif // TITAN_PCBCAM_JOB_H diff --git a/lib/core/layer.cpp b/lib/core/layer.cpp index 3f67e87b50c748ef59ec03f3a5d721977e111473..8c67da3f2d75052aa9be2239f1e2e02c0dd906d1 100644 --- a/lib/core/layer.cpp +++ b/lib/core/layer.cpp @@ -6,9 +6,6 @@ #include <QDebug> #include <QHash> -TITAN_BEGIN_NAMESPACE - - class PcbCamLayerPrivate { @@ -425,4 +422,3 @@ QRectF PcbCamLayer::boundingRect() const return d->boundingRect; } -TITAN_END_NAMESPACE diff --git a/lib/core/layer.h b/lib/core/layer.h index 5ce8b0803f514032315dfd0ae9f7a9ce4015914c..3ee9d2667091ba7ada4881d3f7ae12e87870fc15 100644 --- a/lib/core/layer.h +++ b/lib/core/layer.h @@ -6,7 +6,6 @@ #include <QPainterPath> #include "./common.h" -TITAN_BEGIN_NAMESPACE class PcbCamJob; class PcbCamFeature; @@ -99,6 +98,4 @@ private: }; -TITAN_END_NAMESPACE - #endif // TITAN_PCBCAM_LAYER_H diff --git a/lib/core/math.h b/lib/core/math.h index b0be0a260c6f4ea13a50eb7593697748517dfec6..4eea48a6648eb12c5765102d05d443e7a8609e4b 100644 --- a/lib/core/math.h +++ b/lib/core/math.h @@ -6,7 +6,6 @@ #include <QPolygonF> #include <cmath> -TITAN_BEGIN_NAMESPACE class TITAN_PCBCAM_EXPORT PcbCamMath { @@ -102,6 +101,5 @@ public: }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_MATH_H diff --git a/lib/core/matrixlayer.cpp b/lib/core/matrixlayer.cpp index 251cddd8111f3eb2e2c8fbcdc1fc4b4c43d0988a..9ed70a95f2ac238535aba6887f0467fce9653197 100644 --- a/lib/core/matrixlayer.cpp +++ b/lib/core/matrixlayer.cpp @@ -1,6 +1,5 @@ #include "matrixlayer.h" -TITAN_BEGIN_NAMESPACE class PcbCamMatrixLayerData : public QSharedData { @@ -141,5 +140,3 @@ void PcbCamMatrixLayer::setEndName(const QString &iName) { d->endName = iName; } - -TITAN_END_NAMESPACE diff --git a/lib/core/matrixlayer.h b/lib/core/matrixlayer.h index 200bed82a40d3e791b6a760196deee26628a8be7..13f058532f432d83f1083af6add1a638603c527c 100644 --- a/lib/core/matrixlayer.h +++ b/lib/core/matrixlayer.h @@ -4,7 +4,6 @@ #include <QSharedDataPointer> #include "./common.h" -TITAN_BEGIN_NAMESPACE class PcbCamMatrixLayerData; class TITAN_PCBCAM_EXPORT PcbCamMatrixLayer @@ -46,6 +45,5 @@ private: QSharedDataPointer<PcbCamMatrixLayerData> d; }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_MATRIXLAYER_H diff --git a/lib/core/step.cpp b/lib/core/step.cpp index fe4420bd0daeede1c8403dcc332b1ff40481f4b4..8d9d065e3be6cb77e1558225914fa9a07791df10 100644 --- a/lib/core/step.cpp +++ b/lib/core/step.cpp @@ -1,7 +1,6 @@ #include "step.h" #include <QDebug> -TITAN_BEGIN_NAMESPACE class PcbCamStepData : public QSharedData { @@ -195,4 +194,3 @@ QList<PcbCamSymbolUser *> PcbCamStep::edaPackageSymbols() const return d->edaPackageSymbols; } -TITAN_END_NAMESPACE diff --git a/lib/core/step.h b/lib/core/step.h index 9fb8a4f538de6526230cad2473288fe059269ff6..a3c596118059c1f40e9d32bf19f60a28125ccf78 100644 --- a/lib/core/step.h +++ b/lib/core/step.h @@ -10,7 +10,6 @@ #include "./steprepeat.h" #include "./symbol.h" -TITAN_BEGIN_NAMESPACE class PcbCamStepData; @@ -56,6 +55,4 @@ private: QSharedDataPointer<PcbCamStepData> d; }; -TITAN_END_NAMESPACE - #endif // TITAN_PCBCAM_STEP_H diff --git a/lib/core/steprepeat.cpp b/lib/core/steprepeat.cpp index 76272d9120ebe347ea51cdb4972ba270117e0833..f023e92e3b3089e0c488e22fafe39e6206311908 100644 --- a/lib/core/steprepeat.cpp +++ b/lib/core/steprepeat.cpp @@ -1,6 +1,5 @@ #include "steprepeat.h" -TITAN_BEGIN_NAMESPACE class PcbCamStepRepeatData : public QSharedData { @@ -166,4 +165,3 @@ void PcbCamStepRepeat::setSelected(bool iSelected) d->selected = iSelected; } -TITAN_END_NAMESPACE diff --git a/lib/core/steprepeat.h b/lib/core/steprepeat.h index a2b584463b0ce75c0a93292bd22f26ed0f1b9533..66041efd5a0a5c0945d59079dcd8d856a9a0ac8e 100644 --- a/lib/core/steprepeat.h +++ b/lib/core/steprepeat.h @@ -3,7 +3,6 @@ #include "../titanpcbcamglobal.h" #include <QSharedDataPointer> -TITAN_BEGIN_NAMESPACE class PcbCamStepRepeatData; class TITAN_PCBCAM_EXPORT PcbCamStepRepeat @@ -52,6 +51,5 @@ private: QSharedDataPointer<PcbCamStepRepeatData> d; }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_STEPREPEAT_H diff --git a/lib/core/symbol.cpp b/lib/core/symbol.cpp index 0f8b10017fc70398ce6416320484f8b2b0b8d593..8a8e54ee9b5688dc2b1542e694e0aa187f4477f2 100644 --- a/lib/core/symbol.cpp +++ b/lib/core/symbol.cpp @@ -3,7 +3,6 @@ #include <QtMath> #include <QTransform> -TITAN_BEGIN_NAMESPACE class PcbCamSymbolPrivate { @@ -2040,7 +2039,3 @@ void PcbCamSymbolUser::deleteFeature(int iIndex) } } } - -TITAN_END_NAMESPACE - - diff --git a/lib/core/symbol.h b/lib/core/symbol.h index 79b3cc8acfdafe531677d16ba2b0fbdd8bb2952f..eb5bb51ca87408174bffa15201fd9fe8a7a78111 100644 --- a/lib/core/symbol.h +++ b/lib/core/symbol.h @@ -5,7 +5,6 @@ #include "./feature.h" #include "./common.h" -TITAN_BEGIN_NAMESPACE class PcbCamSymbolPrivate; class TITAN_PCBCAM_EXPORT PcbCamSymbol @@ -503,6 +502,5 @@ private: Q_DISABLE_COPY(PcbCamSymbolUser) }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_SYMBOL_H diff --git a/lib/core/symbolfactory.cpp b/lib/core/symbolfactory.cpp index c05b46c7a6b7e8f0ca5709554b6c29cc361f63fe..0f47d9ef3ae7df8911e7fad30361e89ed1bc6868 100644 --- a/lib/core/symbolfactory.cpp +++ b/lib/core/symbolfactory.cpp @@ -2,7 +2,6 @@ #include <QDebug> #include "./symbol.h" -TITAN_BEGIN_NAMESPACE static QString formatNumber(double iNumber, int iPercision = 6) { @@ -401,6 +400,3 @@ QString PcbCamSymbolFactory::symbolScaledName(const QString &iName, double iScal return iName; } - - -TITAN_END_NAMESPACE diff --git a/lib/core/symbolfactory.h b/lib/core/symbolfactory.h index 793eef08e76eb8267eb7a4f28e65463bd742fc2b..8ccab57c31d36f410ff8450fe33b07dbfa9ddd5d 100644 --- a/lib/core/symbolfactory.h +++ b/lib/core/symbolfactory.h @@ -2,7 +2,6 @@ #define TITAN_PCBCAM_SYMBOLFACTORY_H #include "../titanpcbcamglobal.h" -TITAN_BEGIN_NAMESPACE class PcbCamSymbol; class TITAN_PCBCAM_EXPORT PcbCamSymbolFactory @@ -12,6 +11,5 @@ public: static QString symbolScaledName(const QString &iName, double iScale, int iPercision=6); }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_SYMBOLFACTORY_H diff --git a/lib/core/util.cpp b/lib/core/util.cpp index 095ca84d1c821f3271f7d94d5ef89be64896e177..303e312013aee9d122a78c046cc6fb7bf494109d 100644 --- a/lib/core/util.cpp +++ b/lib/core/util.cpp @@ -11,7 +11,6 @@ #include "./common.h" #include "./feature.h" -TITAN_BEGIN_NAMESPACE static QMap<int, QString> WEEK_DAY_STRING { {1, "MONDAY"}, @@ -43,7 +42,7 @@ QString PcbCamUtil::formatNumber(double iNumber, int iPercision) } -QRectF PcbCamUtil::calcPathArc(const QPointF &iPs, const QPointF &iPe, const QPointF &iPc, bool iCw, double *oStartAngle, double *oSweepLength) +QVariantMap PcbCamUtil::calcPathArc(const QPointF &iPs, const QPointF &iPe, const QPointF &iPc, bool iCw) { qreal xs = iPs.x(); qreal ys = iPs.y(); @@ -71,18 +70,20 @@ QRectF PcbCamUtil::calcPathArc(const QPointF &iPs, const QPointF &iPe, const QPo } } - *oStartAngle = sa * (180.0 / M_PI) ; - *oSweepLength = (ea - sa) * (180.0 / M_PI); - return QRectF(xc - r, yc - r, r * 2.0, r * 2.0); - + QVariantMap retData; + retData.insert("start_angle", sa * (180.0 / M_PI)); + retData.insert("sweep_length", (ea - sa) * (180.0 / M_PI)); + retData.insert("rect", QRectF(xc - r, yc - r, r * 2.0, r * 2.0)); + return retData; } QPainterPath PcbCamUtil::arc2path(const QPointF &iPs, const QPointF &iPe, const QPointF &iPc, bool iCw) { QPainterPath path; - double startAngle; - double sweepLength; - auto rect = calcPathArc(iPs, iPe, iPc, iCw, &startAngle, &sweepLength); + QVariantMap calcData = calcPathArc(iPs, iPe, iPc, iCw); + double startAngle = calcData.value("start_angle").toDouble(); + double sweepLength = calcData.value("sweep_length").toDouble(); + QRectF rect = calcData.value("rect").toRectF(); path.arcMoveTo(rect, startAngle); path.arcTo(rect, startAngle, sweepLength); return path; @@ -648,9 +649,10 @@ QList<QPainterPath> PcbCamUtil::findPolyline(const QList<PcbCamFeature *> &iFeat auto pe = iInvert ? feat->ps() : feat->pe(); auto pc = feat->pc(); bool cw = iInvert ? !feat->cw() : feat->cw(); - double startAngle; - double sweepLength; - auto rect = calcPathArc(ps, pe, pc, cw, &startAngle, &sweepLength); + QVariantMap calcData = calcPathArc(ps, pe, pc, cw); + double startAngle = calcData.value("start_angle").toDouble(); + double sweepLength = calcData.value("sweep_length").toDouble(); + QRectF rect = calcData.value("rect").toRectF(); if (iPath->isEmpty()) { iPath->arcMoveTo(rect, startAngle); iPath->arcTo(rect, startAngle, sweepLength); @@ -715,10 +717,3 @@ QList<QPainterPath> PcbCamUtil::findPolyline(const QList<PcbCamFeature *> &iFeat return allpaths; } - - -TITAN_END_NAMESPACE - - - - diff --git a/lib/core/util.h b/lib/core/util.h index 56e9dcff35e265fdd8f45548285e00b2efb766f2..b2cc040a953d9a39f9476aa432109c06c7cedfc3 100644 --- a/lib/core/util.h +++ b/lib/core/util.h @@ -11,13 +11,12 @@ #include <QPainterPath> #include <QPen> -TITAN_BEGIN_NAMESPACE class TITAN_PCBCAM_EXPORT PcbCamUtil { public: static QString formatNumber(double iNumber, int iPercision = 6); - static QRectF calcPathArc(const QPointF &iPs, const QPointF &iPe, const QPointF &iPc, bool iCw, double *oStartAngle, double *oSweepLength); + static QVariantMap calcPathArc(const QPointF &iPs, const QPointF &iPe, const QPointF &iPc, bool iCw); static QPainterPath arc2path(const QPointF &iPs, const QPointF &iPe, const QPointF &iPc, bool iCw); static QPainterPath line2path(const QLineF &iLine); @@ -59,10 +58,10 @@ public: PcbCam::LogicOperator iExcludeAttrLogic); //点到线段的最çŸè·ç¦» - static double point2segDist(double x, double y, double x1, double y1, double x2, double y2); +// static double point2segDist(double x, double y, double x1, double y1, double x2, double y2); //点到多段线最çŸè·ç¦» - static double point2polylineDist(const QPointF &p, const QPolygonF &polyline); +// static double point2polylineDist(const QPointF &p, const QPolygonF &polyline); //查找å°é—çš„painterpath static QPainterPath findClosedPath(const QList<PcbCamFeature*> &iFeatures, double iTol = 0.0001); @@ -72,6 +71,4 @@ public: }; -TITAN_END_NAMESPACE - #endif // TITAN_PCBCAM_UTIL_H diff --git a/lib/lib.pro b/lib/lib.pro index b4af1b8a89f44c6a278ab7f625c87b9752fe1fd5..47c813a8c4240928369850f49c2a7e3b102d0a69 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -1,18 +1,19 @@ #----------------项目设置---------------------------------------------------- PROJECT_NAME = titan_pcbcam -ROOT_DIR = $$PWD/../../ +ROOT_DIR = $$PWD/../ HEADER_DIR = titan/pcbcam DLL_LIBS = STATIC_LIBS = -VERSION = 2.0.2 +VERSION = 2.0.3 #----------------编译设置--------------------------------------------------- TEMPLATE = lib ##CONFIG += staticlib ### Library Export -CONFIG(staticlib) : DEFINES += $$upper($${PROJECT_NAME})_STATIC -else : DEFINES += $$upper($${PROJECT_NAME})_SHARED +#CONFIG(staticlib) : DEFINES += $$upper($${PROJECT_NAME})_STATIC +#else : DEFINES += $$upper($${PROJECT_NAME})_SHARED +DEFINES += BINDINGS_BUILD TARGET = $$qtLibraryTarget($${PROJECT_NAME}) @@ -40,7 +41,7 @@ include(pcbcam.pri) #----------------其它编译设定---------------------------------------------- SRC_PWD = $$PWD -include($${ROOT_DIR}/shared/shared.pri) +include(shared.pri) ### 导出头文件 ### diff --git a/lib/parser/drillparser.cpp b/lib/parser/drillparser.cpp index a8e76c743ec070e858c7867a57fcfe94c58a55a8..fd19046a2c7a0367ce2d20c5ef151496575fe863 100644 --- a/lib/parser/drillparser.cpp +++ b/lib/parser/drillparser.cpp @@ -7,7 +7,6 @@ #include <functional> #include "../core/util.h" -TITAN_BEGIN_NAMESPACE class PcbCamDrillToolData: public QSharedData { @@ -1125,7 +1124,7 @@ bool PcbCamDrillParser::parser() drlfile.close(); - d->walkDrillRows(drillrows, d->statement, [this](const PcbCamDrillParserPrivate::RowData &rowdata){ + return d->walkDrillRows(drillrows, d->statement, [this](const PcbCamDrillParserPrivate::RowData &rowdata){ if (rowdata.section == PcbCamDrillParserPrivate::Section::Head ) { if (rowdata.cmd == PcbCamDrillParserPrivate::Cmd::TCODE) { auto tool = rowdata.tool; @@ -1341,6 +1340,3 @@ QVariantMap PcbCamDrillParser::DrillStatement::toMap() const {"decimalDigits", this->decimalDigits}, }; } - - -TITAN_END_NAMESPACE diff --git a/lib/parser/drillparser.h b/lib/parser/drillparser.h index 98fce52da4a93aa34811201c562003a6d657a6c2..5e5336dfd75aae425f1359f2f4539b26e93b4990 100644 --- a/lib/parser/drillparser.h +++ b/lib/parser/drillparser.h @@ -3,7 +3,6 @@ #include "../titanpcbcamglobal.h" #include "odbfeatureparser.h" -TITAN_BEGIN_NAMESPACE class PcbCamDrillParserPrivate; class TITAN_PCBCAM_EXPORT PcbCamDrillParser @@ -56,6 +55,5 @@ private: }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_DRILLPARSER_H diff --git a/lib/parser/gerber274xparser.cpp b/lib/parser/gerber274xparser.cpp index c88fd5aedfebd019075905ec90e1eb005911800e..d969f00c00eaa7674f7ddd9785af25232d11178c 100644 --- a/lib/parser/gerber274xparser.cpp +++ b/lib/parser/gerber274xparser.cpp @@ -11,9 +11,6 @@ #include <QtMath> #include "../core/util.h" -TITAN_BEGIN_NAMESPACE - - class PcbCamGerber274XParserPrivate { @@ -94,7 +91,7 @@ public: // ä»¥ä¸‹ä¸ºæ—§ç‰ˆæ ¼å¼å‘½ä»¤ - { PcbCamGerber274XParser::Cmd::IN, QRegularExpression("^(?<cmd>IN)(?<name>.*)")}, + { PcbCamGerber274XParser::Cmd::INN, QRegularExpression("^(?<cmd>IN)(?<name>.*)")}, { PcbCamGerber274XParser::Cmd::IP, QRegularExpression("^(?<cmd>IP)(?<mode>(POS|NEG))")}, { PcbCamGerber274XParser::Cmd::IR, QRegularExpression("^(?<cmd>IR)(?<angle>[\\+\\-]?\\d+>)")}, { PcbCamGerber274XParser::Cmd::OF, QRegularExpression("^(?<cmd>IO)(A(?<a>[\\+\\-]?\\d+(\\.?\\d+)?))?(B(?<b>[\\+\\-]?\\d+(\\.?\\d+)?))?")}, @@ -790,9 +787,10 @@ void PcbCamGerber274XParser::parse(QIODevice *iIODevice) auto ps = d->graphicsState.currentPoint; bool cw = d->graphicsState.interpolationMode == PcbCamGerber274XParserPrivate::ClockwiseCircularMode; auto pc = d->calcArcCenter(ps, pos, d->coord2inch(coordparam.value("i", "0")), d->coord2inch(coordparam.value("j", "0")), cw, d->graphicsState.quadrantMode); - double startAngle; - double sweepLength; - auto arcrect = PcbCamUtil::calcPathArc(ps, pos, pc, cw, &startAngle, &sweepLength); + QVariantMap calcData = PcbCamUtil::calcPathArc(ps, pos, pc, cw); + double startAngle = calcData.value("start_angle").toDouble(); + double sweepLength = calcData.value("sweep_length").toDouble(); + QRectF arcrect = calcData.value("rect").toRectF(); d->curRegionPath.arcTo(arcrect, startAngle, sweepLength); } } @@ -970,7 +968,7 @@ void PcbCamGerber274XParser::parse(QIODevice *iIODevice) // Include File // TODO } - else if (cmd == Cmd::IN) { + else if (cmd == Cmd::INN) { // Image Name, just a comment } else if (cmd == Cmd::LN) { @@ -1011,14 +1009,8 @@ QList<PcbCamOdbFeatureInfo> PcbCamGerber274XParser::features() const return d->featureList; } -QMap<int, PcbCamGerber274XParser::ApertureInfo> PcbCamGerber274XParser::apertures() const +QList<PcbCamGerber274XParser::ApertureInfo> PcbCamGerber274XParser::apertures() const { Q_D(const PcbCamGerber274XParser); - return d->apertures; + return d->apertures.values(); } - - - - -TITAN_END_NAMESPACE - diff --git a/lib/parser/gerber274xparser.h b/lib/parser/gerber274xparser.h index 4fb9c5640c11955fb1cddb7f8fc5e8d5de5f3d1c..7a2156f0058ef8a78e26332b6052fd28ad73c530 100644 --- a/lib/parser/gerber274xparser.h +++ b/lib/parser/gerber274xparser.h @@ -3,7 +3,7 @@ #include "../titanpcbcamglobal.h" #include "odbfeatureparser.h" -TITAN_BEGIN_NAMESPACE +class QIODevice; class PcbCamGerber274XParserPrivate; class TITAN_PCBCAM_EXPORT PcbCamGerber274XParser @@ -11,6 +11,7 @@ class TITAN_PCBCAM_EXPORT PcbCamGerber274XParser public: struct ApertureInfo { + explicit ApertureInfo(){} int dcode {0}; QString name; bool isStandard {true}; @@ -18,7 +19,7 @@ public: }; - enum class Cmd { + enum class Cmd { COORD = 0, APERTURE_SELECT = 1, FS, @@ -37,7 +38,7 @@ public: // ä»¥ä¸‹ä¸ºæ—§ç‰ˆæ ¼å¼å‘½ä»¤ AS, - IN, + INN, IP, IR, IO, @@ -49,20 +50,18 @@ public: DEPRECATED_FORMAT, UNKNOW , - EMPTY, - + EMPTY }; - PcbCamGerber274XParser(); + explicit PcbCamGerber274XParser(); ~PcbCamGerber274XParser(); void parse(QIODevice *iIODevice); - QStringList errors(); QList<PcbCamOdbFeatureInfo> features() const; - QMap<int, ApertureInfo> apertures() const; + QList<ApertureInfo> apertures() const; protected: const QScopedPointer<PcbCamGerber274XParserPrivate> d_ptr; @@ -72,6 +71,5 @@ private: Q_DISABLE_COPY(PcbCamGerber274XParser) }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_GERBER274XPARSER_H diff --git a/lib/parser/odbcomponentparser.cpp b/lib/parser/odbcomponentparser.cpp index 8f76e640785ee686e4b07ea2bef76c75fa0eee68..d1e5e5f4208ca95410449cdd6e7ef279b576c7dc 100644 --- a/lib/parser/odbcomponentparser.cpp +++ b/lib/parser/odbcomponentparser.cpp @@ -3,7 +3,6 @@ #include <QStringList> #include <QtMath> -TITAN_BEGIN_NAMESPACE class PcbCamOdbComponentParserPrivate { @@ -155,5 +154,3 @@ void PcbCamOdbComponentParser::parseAttributes(const QString &iLine, QStringList } } - -TITAN_END_NAMESPACE diff --git a/lib/parser/odbcomponentparser.h b/lib/parser/odbcomponentparser.h index a3498d8acadab0947e5efed527c3ee5f4870266e..31b6078c2f869122b37ade003f42c6a4230755ff 100644 --- a/lib/parser/odbcomponentparser.h +++ b/lib/parser/odbcomponentparser.h @@ -3,7 +3,6 @@ #include "../titanpcbcamglobal.h" #include "odbfeatureparser.h" -TITAN_BEGIN_NAMESPACE class PcbCamOdbComponentParserPrivate; class TITAN_PCBCAM_EXPORT PcbCamOdbComponentParser @@ -31,6 +30,5 @@ private: }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_ODBCOMPONENTPARSER_H diff --git a/lib/parser/odbedadataparser.cpp b/lib/parser/odbedadataparser.cpp index 87578d472ad45d6f522e1190f08bb5a539f8b8c1..8a30df5338ac7496bde2a4f6090be7121e944396 100644 --- a/lib/parser/odbedadataparser.cpp +++ b/lib/parser/odbedadataparser.cpp @@ -2,7 +2,6 @@ #include <QTextStream> #include <QtMath> -TITAN_BEGIN_NAMESPACE class PcbCamOdbEdaDataParserPrivate { @@ -154,8 +153,6 @@ QStringList PcbCamOdbEdaDataParser::errors() return d->errorList; } - - void PcbCamOdbEdaDataParser::parseSurfaceLine(const QString &iLine) { Q_D(PcbCamOdbEdaDataParser); @@ -203,4 +200,3 @@ void PcbCamOdbEdaDataParser::parseSurfaceLine(const QString &iLine) } } -TITAN_END_NAMESPACE diff --git a/lib/parser/odbedadataparser.h b/lib/parser/odbedadataparser.h index 72d349d35a40a5b1e5ea630a3811d19808f2a0c8..d7f857e047daa6a16de7ee74cec2ec32f614a60b 100644 --- a/lib/parser/odbedadataparser.h +++ b/lib/parser/odbedadataparser.h @@ -3,7 +3,6 @@ #include "../titanpcbcamglobal.h" #include "odbfeatureparser.h" -TITAN_BEGIN_NAMESPACE class PcbCamOdbEdaDataParserPrivate; class TITAN_PCBCAM_EXPORT PcbCamOdbEdaDataParser @@ -26,6 +25,5 @@ private: Q_DISABLE_COPY(PcbCamOdbEdaDataParser) }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_ODBEDAPACKAGEPARSER_H diff --git a/lib/parser/odbfeatureparser.cpp b/lib/parser/odbfeatureparser.cpp index bcf9521eca3f01f4620e1f0d97d4438f31ede197..3ac7b066dd0fd0da7587b47a3b7f5f3cca5e8179 100644 --- a/lib/parser/odbfeatureparser.cpp +++ b/lib/parser/odbfeatureparser.cpp @@ -4,7 +4,6 @@ #include <QtMath> #include "../core/util.h" -TITAN_BEGIN_NAMESPACE class PcbCamOdbFeatureParserPrivate { @@ -285,9 +284,10 @@ void PcbCamOdbFeatureParser::parseSurfaceLine(const QString &iLine) qreal ex = param.value(1).toDouble(), ey = param.value(2).toDouble(); qreal cx = param.value(3).toDouble(), cy = param.value(4).toDouble(); bool cw = param.value(5) == "Y" ? true : false; - double startAngle; - double sweepLength; - auto arcrect = PcbCamUtil::calcPathArc(QPointF(sx, sy), QPointF(ex, ey), QPointF(cx, cy), cw, &startAngle, &sweepLength); + QVariantMap calcData = PcbCamUtil::calcPathArc(QPointF(sx, sy), QPointF(ex, ey), QPointF(cx, cy), cw); + double startAngle = calcData.value("start_angle").toDouble(); + double sweepLength = calcData.value("sweep_length").toDouble(); + QRectF arcrect = calcData.value("rect").toRectF(); d->lastPath.arcTo(arcrect, startAngle, sweepLength); @@ -347,4 +347,3 @@ void PcbCamOdbFeatureParser::parseAttributes(const QString &iLine, QStringList * } } -TITAN_END_NAMESPACE diff --git a/lib/parser/odbfeatureparser.h b/lib/parser/odbfeatureparser.h index 0b8d7220d90ad9b645529283100fdf420306b0e7..c773862cfdec688e3629f95e5d834f27e6041893 100644 --- a/lib/parser/odbfeatureparser.h +++ b/lib/parser/odbfeatureparser.h @@ -8,7 +8,6 @@ #include <QSizeF> #include "../core/common.h" -TITAN_BEGIN_NAMESPACE struct PcbCamOdbFeatureInfo { PcbCam::FeatureType type {PcbCam::PadFeature}; @@ -73,6 +72,5 @@ private: Q_DISABLE_COPY(PcbCamOdbFeatureParser) }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_ODBFEATUREPARSERV2_H diff --git a/lib/parser/odbmatrixparser.cpp b/lib/parser/odbmatrixparser.cpp index e0d168197bddf553661bb8771b6a69fd7430ca91..9e3bd59c48e85d24f0dc2bb5c45e4e84d088469c 100644 --- a/lib/parser/odbmatrixparser.cpp +++ b/lib/parser/odbmatrixparser.cpp @@ -2,7 +2,6 @@ #include <QFile> #include <QTextStream> -TITAN_BEGIN_NAMESPACE class PcbCamOdbMatrixParserPrivate { @@ -148,4 +147,3 @@ QStringList PcbCamOdbMatrixParser::errors() const return d->errors; } -TITAN_END_NAMESPACE diff --git a/lib/parser/odbmatrixparser.h b/lib/parser/odbmatrixparser.h index d790c4b5518fc3181d05170726ec62c64f555e0b..b2159dbf9fb2fd2e54ac23c697f01f910d0ca8f2 100644 --- a/lib/parser/odbmatrixparser.h +++ b/lib/parser/odbmatrixparser.h @@ -5,7 +5,6 @@ #include <QMap> #include "../core/matrixlayer.h" -TITAN_BEGIN_NAMESPACE class PcbCamOdbMatrixParserPrivate; class TITAN_PCBCAM_EXPORT PcbCamOdbMatrixParser : public QObject @@ -32,6 +31,5 @@ private: }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_ODBMATRIXPARSER_H diff --git a/lib/parser/parserhelper.cpp b/lib/parser/parserhelper.cpp index ff9a6ebc9e01209721a53e3deeb28394e47c31a4..267d9d4b269dd29d349ecd6d67a2e382de619af3 100644 --- a/lib/parser/parserhelper.cpp +++ b/lib/parser/parserhelper.cpp @@ -6,11 +6,9 @@ #include <QDebug> #include "../core/font.h" -TITAN_BEGIN_NAMESPACE -QVariantMap PcbCamParserHelper::parseOdbStructuredText(const QByteArray &iData, QString *oErrStr) +QVariantMap PcbCamParserHelper::parseOdbStructuredText(const QByteArray &iData) { - if (oErrStr != nullptr) oErrStr->clear(); QByteArray data = iData; QVariantMap res; @@ -59,9 +57,8 @@ QVariantMap PcbCamParserHelper::parseOdbStructuredText(const QByteArray &iData, return res; } -QPainterPath PcbCamParserHelper::parseOdbProfile(const QByteArray &iData, QString *oErrStr) +QPainterPath PcbCamParserHelper::parseOdbProfile(const QByteArray &iData) { - if (oErrStr != nullptr) oErrStr->clear(); QByteArray data = iData; QTextStream stream(&data); QString line; @@ -121,10 +118,9 @@ QPainterPath PcbCamParserHelper::parseOdbProfile(const QByteArray &iData, QStrin return res; } -bool PcbCamParserHelper::parseOdbFont(const QByteArray &iData, PcbCamFont *oFont, QString *oErrStr) +bool PcbCamParserHelper::parseOdbFont(const QByteArray &iData, PcbCamFont *oFont) { if (oFont == nullptr) return false; - if (oErrStr != nullptr) oErrStr->clear(); QList<PcbCamFontCharLine> currentCharLines; QChar currentChar; @@ -186,4 +182,3 @@ PcbCamParserHelper::PcbCamParserHelper() } -TITAN_END_NAMESPACE diff --git a/lib/parser/parserhelper.h b/lib/parser/parserhelper.h index a5227b44b5cd68494d01b161018d039afe0293c6..c56b2dd3fad109bde096975cf5148ce63152492c 100644 --- a/lib/parser/parserhelper.h +++ b/lib/parser/parserhelper.h @@ -4,20 +4,18 @@ #include <QVariantMap> #include <QPainterPath> -TITAN_BEGIN_NAMESPACE class PcbCamFont; class TITAN_PCBCAM_EXPORT PcbCamParserHelper { public: - static QVariantMap parseOdbStructuredText(const QByteArray &iData, QString *oErrStr = nullptr); - static QPainterPath parseOdbProfile(const QByteArray &iData, QString *oErrStr = nullptr); - static bool parseOdbFont(const QByteArray &iData, PcbCamFont *oFont, QString *oErrStr = nullptr); + static QVariantMap parseOdbStructuredText(const QByteArray &iData); + static QPainterPath parseOdbProfile(const QByteArray &iData); + static bool parseOdbFont(const QByteArray &iData, PcbCamFont *oFont); private: PcbCamParserHelper(); }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_PARSERHELPER_H diff --git a/lib/shared.pri b/lib/shared.pri new file mode 100644 index 0000000000000000000000000000000000000000..aa73b0cf84b88c21148032878e954c8bc51547aa --- /dev/null +++ b/lib/shared.pri @@ -0,0 +1,219 @@ +#------------------------------------------------------------------------------- +# æ¤å·¥ç¨‹æ˜¯titanframework下所有工程文件共用的部分,主è¦åŒ…å«ç³»ç»Ÿåˆ¤å®šï¼Œç¼–è¯‘ç›®å½•è®¾ç½®ç‰ +# +# Author: Tony Guo +#------------------------------------------------------------------------------- + +### é»˜è®¤çš„ç¼–è¯‘ç›®æ ‡ç›®å½• ### +isEmpty(DIST_DIR){ + DIST_DIR = $${ROOT_DIR}/dist +} + +DEFINES += APP_VERSION=\\\"$${VERSION}\\\" +### 为了防æ¢åœ¨windows下编译出的dll带版本数å—的问题 ### +win32:VERSION= + +DEFINES += QT_NO_FOREACH + +win32-msvc* { + ### Window XPæ”¯æŒ ### + QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01 + ### generating pdb in release mode ### + QMAKE_CXXFLAGS_RELEASE += /Zi + QMAKE_LFLAGS_RELEASE += /DEBUG +} + +### 获å–系统平å°åç§°(platform) ### +TANCC=$$section(QMAKESPEC, /, -3, -3) +TANOS=$$(TANPM_OSNAME) +isEmpty(TANOS){ + TANOS=unknowos + win32 { + TANOS=windows + } + linux { + TANOS=linux + } + macx { + TANOS=macx + } +} +TANPLATFORM=$${TANOS}-$${TANCC}-qt$$[QT_VERSION] + +### 定义DIST_PLATFORM ### +DIST_PLATFORM=$${DIST_DIR}/$${TANPLATFORM} + +DEFINES += APP_PLATFORM=\\\"$${TANPLATFORM}\\\" + + +### C++11æ”¯æŒ ### +CONFIG += c++11 + +### 设置DEBUG模å¼åŽç¼€ ### +CONFIG += debug_and_release +CONFIG(debug, debug | release) { + win32 { + DEBUG_SUFFIX = d + } + macx { + DEBUG_SUFFIX = _debug + } +} else { + DEBUG_SUFFIX = +} + +### è®¾ç½®ç¼–è¯‘ç›®æ ‡ç›®å½• ### +DIST_BIN = $$system_path($${DIST_PLATFORM}/bin) +DIST_LIB = $$system_path($${DIST_PLATFORM}/lib) +DIST_STATICLIB = $$system_path($${DIST_PLATFORM}/static) + +DESTDIR = $${DIST_BIN} +equals(TEMPLATE, "lib") { + CONFIG(staticlib) { + CONFIG(debug, debug | release) { + DESTDIR = $${DIST_STATICLIB}/debug + } else { + DESTDIR = $${DIST_STATICLIB}/release + } + } + else { + CONFIG(debug, debug | release) { + DESTDIR = $${DIST_LIB}/debug + } else { + DESTDIR = $${DIST_LIB}/release + } + } +} + +### 定义TOPSIN_SDK头文件目录 ### +INCLUDEPATH += $${DIST_PLATFORM}/include + +### 编译link设置 ### +for (lib, DLL_LIBS) { + tanpmlibpath = $${DIST_PLATFORM}/tanpm/$${lib} + exists($${tanpmlibpath}) { + INCLUDEPATH += $${tanpmlibpath}/include + CONFIG(debug, debug | release) { + exists($${tanpmlibpath}/lib/debug) { + LIBS += -L$${tanpmlibpath}/lib/debug -l$${lib}$${DEBUG_SUFFIX} + } else { + LIBS += -L$${tanpmlibpath}/lib/release -l$${lib} + } + } else { + LIBS += -L$${tanpmlibpath}/lib/release -l$${lib} + } + } + else { + CONFIG(debug, debug | release) { + exists($${DIST_LIB}/debug) { + LIBS += -L$${DIST_LIB}/debug -l$${lib}$${DEBUG_SUFFIX} + } else { + LIBS += -L$${DIST_LIB}/release -l$${lib} + } + } else { + LIBS += -L$${DIST_LIB}/release -l$${lib} + } + } +} + +for (lib, STATIC_LIBS) { + tanpmlibpath = $${DIST_PLATFORM}/tanpm/$${lib} + exists($${tanpmlibpath}) { + INCLUDEPATH += $${tanpmlibpath}/include + exists($${tanpmlibpath}/static) { + DEFINES += $$upper($${lib})_STATIC + CONFIG(debug, debug | release) { + exists($${tanpmlibpath}/static/debug) { + LIBS += -L$${tanpmlibpath}/static/debug -l$${lib}$${DEBUG_SUFFIX} + } else { + LIBS += -L$${tanpmlibpath}/static/release -l$${lib} + } + } else { + LIBS += -L$${tanpmlibpath}/static/release -l$${lib} + } + } + } + else { + CONFIG(debug, debug | release) { + exists($${DIST_STATICLIB}/debug) { + LIBS += -L$${DIST_STATICLIB}/debug -l$${lib}$${DEBUG_SUFFIX} + } else { + LIBS += -L$${DIST_STATICLIB}/release -l$${lib} + } + } else { + LIBS += -L$${DIST_STATICLIB}/release -l$${lib} + } + } +} + +### 导出头文件 ### +equals(TEMPLATE, "lib") { + ### 查看SDKå¤´æ–‡ä»¶ç›®æ ‡è·¯å¾„æ˜¯å¦å˜åœ¨ï¼Œä¸å˜åœ¨åˆ™åˆ›å»º ### + DIST_HEADER = $$system_path($${DIST_PLATFORM}/include/$${HEADER_DIR}) + !exists($${DIST_HEADER}) { + mkpath($${DIST_HEADER}) + } + + ### 导出header ### + win32 { + system(copy $$system_path($${SRC_PWD}/*.h) $${DIST_HEADER}) + } else { + system(cp $$system_path($${SRC_PWD}/*.h) $${DIST_HEADER}) + } +} + +### å¤åˆ¶è¯è¨€åŒ….qm ### +!isEmpty(QM_LIST) { + DIST_LANGUAGE = $$system_path($${DIST_PLATFORM}/lang) + !exists($${DIST_LANGUAGE}) { + mkpath($${DIST_LANGUAGE}) + } + for(qm, QM_LIST) { + win32{ + system(copy $$system_path($${qm}) $${DIST_LANGUAGE}) + } + else{ + system(cp $$system_path($${qm}) $${DIST_LANGUAGE}) + } + } +} + + + +### 设置Macx rpath ### +macx { + QMAKE_LFLAGS += -Wl,-rpath,@loader_path,-rpath,@executable_path + QMAKE_LFLAGS += -Wl,-rpath,@executable_path/../lib + QMAKE_SONAME_PREFIX = @rpath +} + +### 设置Linux rpath ### +linux { + QMAKE_RPATHDIR += . + QMAKE_RPATHDIR += ../lib +} + +################################# COPYRIGHT ################################### +# # +# Copyright (c) 2009-2020 TopLinker Co.,Ltd. (http://www.toplinker.net) # +# ALL RIGHTS RESERVED # +# # +# The entire contents of this file is protected by copyright law and # +# international treaties. Unauthorized reproduction, reverse-engineering # +# and distribution of all or any portion of the code contained in this # +# file is strictly prohibited and may result in severe civil and # +# criminal penalties and will be prosecuted to the maximum extent # +# possible under the law. # +# # +# RESTRICTIONS # +# # +# THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED # +# FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE # +# COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE # +# AVAILABLE TO OTHER INDIVIDUALS WITHOUT WRITTEN CONSENT # +# AND PERMISSION FROM DEVELOPER MACHINES # +# # +# CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON # +# ADDITIONAL RESTRICTIONS. # +# # +################################################################################ diff --git a/lib/titanpcbcamglobal.h b/lib/titanpcbcamglobal.h index 33d21f81721dba9049c8dcf25a923c4f7c6e61db..0df43e6c715aee6fe8eb06c0ba78a8a797d13c13 100644 --- a/lib/titanpcbcamglobal.h +++ b/lib/titanpcbcamglobal.h @@ -1,17 +1,11 @@ #ifndef TITAN_PCBCAM_GLOBAL_H #define TITAN_PCBCAM_GLOBAL_H #include <QtCore/qglobal.h> -#if !defined(TITAN_PCBCAM_STATIC) -# if defined(TITAN_PCBCAM_SHARED) -# define TITAN_PCBCAM_EXPORT Q_DECL_EXPORT -# else -# define TITAN_PCBCAM_EXPORT Q_DECL_IMPORT -# endif + +#if BINDINGS_BUILD +# define TITAN_PCBCAM_EXPORT Q_DECL_EXPORT #else -# define TITAN_PCBCAM_EXPORT +# define TITAN_PCBCAM_EXPORT Q_DECL_IMPORT #endif -#define TITAN_BEGIN_NAMESPACE namespace titan { -#define TITAN_END_NAMESPACE } - #endif // TITAN_PCBCAM_GLOBAL_H diff --git a/lib/widget/canvas.cpp b/lib/widget/canvas.cpp index 51a64c313e8d70a07d7a611ecb8e3cc3ab4b5157..9f01ba18764380ff04a17d2b2e7c412771e09df0 100644 --- a/lib/widget/canvas.cpp +++ b/lib/widget/canvas.cpp @@ -6,14 +6,12 @@ #include <QWheelEvent> #include <QMenu> #include <QStack> -#include "../core/arcpainterinfo.h" #include "../core/util.h" #include "../core/math.h" #include "../core/symbol.h" #include "../core/feature.h" #include "./popviewwindow.h" -TITAN_BEGIN_NAMESPACE struct PopViewInfo { QRectF canvasRect; @@ -240,7 +238,7 @@ void PcbCamCanvas::viewLeft(qreal iRate) { Q_D(PcbCamCanvas); QRectF rect = d->orientMatrix.mapRect(d->currentDisplayRect).normalized(); - rect.moveLeft(rect.left() - rect.width()*iRate); + rect.moveRight(rect.right() + rect.width()*iRate); rect = d->orientMatrix.inverted().mapRect(rect).normalized(); fitInView(rect); } @@ -249,7 +247,7 @@ void PcbCamCanvas::viewRight(qreal iRate) { Q_D(PcbCamCanvas); QRectF rect = d->orientMatrix.mapRect(d->currentDisplayRect).normalized(); - rect.moveRight(rect.right() + rect.width()*iRate); + rect.moveLeft(rect.left() - rect.width()*iRate); rect = d->orientMatrix.inverted().mapRect(rect).normalized(); fitInView(rect); } @@ -277,7 +275,7 @@ void PcbCamCanvas::setOrientMatrix(const QTransform &iMatrix) Q_D(PcbCamCanvas); d->orientMatrix = iMatrix; auto rect = d->currentDisplayRect.normalized(); - qreal size = qMin(rect.width(), rect.height()); + qreal size = qMax(rect.width(), rect.height()); this->fitInView(QRectF(rect.center().x() - size/2.0, rect.center().y() - size/2.0, size, size), false); } @@ -606,7 +604,7 @@ QVariantMap PcbCamCanvas::snapFeatInfo(const QPoint &iPoint, int iTolPix) res.insert("angle", PcbCamUtil::orient2angle(feat->orient())); res.insert("mirror", PcbCamUtil::orient2mirror(feat->orient())); } - emit snapFeatChanged(res); + emit snapFeatChanged(QVariant::fromValue(res)); } return res; } @@ -1454,14 +1452,21 @@ QPixmap PcbCamCanvas::renderChkMeans(const QTransform &iMatrix, const QSize &iSi return pixmap; } -QPointF PcbCamCanvas::getSnapPoint(const QPoint &iCursorPos, int iSnapRange, bool *oSnaped) +QVariantMap PcbCamCanvas::getSnapPoint(const QPoint &iCursorPos, int iSnapRange) { Q_D(PcbCamCanvas); + QVariantMap retData; d->isSnapPointValid = false; - if (oSnaped != nullptr) *oSnaped = false; - if (d->jobData == nullptr) return QPointF(); + retData.insert("snaped", false); + if (d->jobData == nullptr) { + retData.insert("point", QPointF()); + return retData; + } QPointF curpos = mapToScene(iCursorPos); - if (d->snapMode == PcbCam::SnapOff) return curpos; + if (d->snapMode == PcbCam::SnapOff) { + retData.insert("point", curpos); + return retData; + } QRectF range = mapToScene(QRect(iCursorPos.x() - iSnapRange, iCursorPos.y() - iSnapRange, iSnapRange*2, iSnapRange *2)); @@ -1503,13 +1508,15 @@ QPointF PcbCamCanvas::getSnapPoint(const QPoint &iCursorPos, int iSnapRange, boo } if (snapExists && scaledRange.contains(snapPoint)) { - if (oSnaped != nullptr) *oSnaped = true; + retData.insert("snaped", true); d->isSnapPointValid = true; d->snapPoint = mat.inverted().map(snapPoint); - return d->snapPoint; + retData.insert("point", d->snapPoint); + return retData; } else { - return curpos; + retData.insert("point", curpos); + return retData; } } @@ -2013,7 +2020,7 @@ bool PcbCamCanvas::event(QEvent *iEvent) if (d->mouseClickTimes == 0 && iEvent->type() == QEvent::MouseButtonPress ) { QMouseEvent *evt = static_cast<QMouseEvent*>(iEvent); if (evt->button() == Qt::LeftButton) { - QPointF sp = getSnapPoint(evt->pos()); + QPointF sp = getSnapPoint(evt->pos()).value("point").toPointF(); d->measureLine.setP1(sp); d->measureLine.setP2(d->measureLine.p1()); d->rubberBandRect.setTopLeft(sp); @@ -2024,12 +2031,12 @@ bool PcbCamCanvas::event(QEvent *iEvent) } else if (d->mouseClickTimes == 0 && iEvent->type() == QEvent::MouseMove) { QMouseEvent *evt = static_cast<QMouseEvent*>(iEvent); - getSnapPoint(evt->pos()); + getSnapPoint(evt->pos()).value("point").toPointF(); update(); } else if (d->mouseClickTimes == 1 && iEvent->type() == QEvent::MouseMove) { QMouseEvent *evt = static_cast<QMouseEvent*>(iEvent); - QPointF sp = getSnapPoint(evt->pos()); + QPointF sp = getSnapPoint(evt->pos()).value("point").toPointF(); d->measureLine.setP2(sp); d->rubberBandRect.setBottomRight(sp); update(); @@ -2242,7 +2249,7 @@ void PcbCamCanvas::paintEvent(QPaintEvent */*iEvent*/) auto dispopt = d->displayOptions; dispopt |= PcbCam::DisplayNegative; QRectF srect; - for (auto hinfo : d->highlightBuffer) { + for (auto &hinfo : d->highlightBuffer) { auto mat = hinfo.matrix * d->currentMatrix; srect = mat.inverted().mapRect(QRectF(this->rect())); PcbCamUtil::drawFeatures(&painter, @@ -2539,5 +2546,3 @@ void PcbCamCanvas::contextMenuEvent(QContextMenuEvent *event) // } } - -TITAN_END_NAMESPACE diff --git a/lib/widget/canvas.h b/lib/widget/canvas.h index 4adc436cc0907244f0d3f0a6f1948d6bb5305761..3ac835e3b28c60f89d79174e419bba0f15452382 100644 --- a/lib/widget/canvas.h +++ b/lib/widget/canvas.h @@ -7,7 +7,6 @@ #include <QEvent> #include "../core/job.h" -TITAN_BEGIN_NAMESPACE class PcbCamPopViewWindow; @@ -57,7 +56,7 @@ signals: void displayUpdated(); void selectionChanged(); void keyPressed(const QString &iKey); - void snapFeatChanged(const QVariantMap &iInfo); + void snapFeatChanged(const QVariant &iInfo); public slots: void setJobData(PcbCamJob *iJob); @@ -148,7 +147,7 @@ public slots: void setSnapFeatureType(PcbCam::FeatureTypes iType); PcbCam::FeatureTypes snapFeatureType() const; - QPointF getSnapPoint(const QPoint &iCursorPos, int iSnapRange = 20, bool *oSnaped = nullptr); + QVariantMap getSnapPoint(const QPoint &iCursorPos, int iSnapRange = 20); void getSnapPathsInRect(const QString &iStep, const QRectF &iRange, bool iIncludeStepRepeat, const QTransform &iMatrix, QPainterPath &oSnapFeatPaths, QPolygonF &oSnapFeatPoints) const; void setDisplayOption(PcbCam::DisplayOptions iDispOption); @@ -197,6 +196,5 @@ private: Q_DISABLE_COPY(PcbCamCanvas) }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_GRAPHVIEW_H diff --git a/lib/widget/popviewwindow.cpp b/lib/widget/popviewwindow.cpp index 648b1185592461cede3247bf62becfb8efe09f4d..ace5d3a24ac967796a701ecb30408e524acd32d8 100644 --- a/lib/widget/popviewwindow.cpp +++ b/lib/widget/popviewwindow.cpp @@ -4,14 +4,12 @@ #include <QHBoxLayout> #include <QToolBar> #include <QPushButton> -#include <QCloseEvent> #include <QGraphicsDropShadowEffect> #include <QPainter> #include <QApplication> #include "canvas.h" #include <QDebug> -TITAN_BEGIN_NAMESPACE static QIcon coloredIcon(const QIcon &iIcon, const QColor &iColor) { @@ -99,7 +97,7 @@ protected: }; -PcbCamPopViewWindow::PcbCamPopViewWindow(const QRectF &iSourceRect, const QRect &iTargetRect, titan::PcbCamCanvas *iCanvas): QFrame(iCanvas), +PcbCamPopViewWindow::PcbCamPopViewWindow(const QRectF &iSourceRect, const QRect &iTargetRect, PcbCamCanvas *iCanvas): QFrame(iCanvas), d_ptr(new PcbCamPopViewWindowPrivate(this)) { Q_D(PcbCamPopViewWindow); @@ -411,8 +409,3 @@ void PcbCamPopViewWindow::onZoomOutClicked() emit geometryChanged(); this->refresh(); } - - - - -TITAN_END_NAMESPACE diff --git a/lib/widget/popviewwindow.h b/lib/widget/popviewwindow.h index 2391451fbf69f90e8519482fda758508044c7437..63609b9467169b286cbb43c889243f8fd5f7b303 100644 --- a/lib/widget/popviewwindow.h +++ b/lib/widget/popviewwindow.h @@ -2,18 +2,20 @@ #define TITAN_PCBCAM_POPVIEWWINDOW_H #include "../titanpcbcamglobal.h" #include <QFrame> +#include <QResizeEvent> +#include <QCloseEvent> +#include <QMoveEvent> +#include <QMouseEvent> - -TITAN_BEGIN_NAMESPACE class PcbCamCanvas; class PcbCamPopViewWindowPrivate; -class PcbCamPopViewWindow : public QFrame +class TITAN_PCBCAM_EXPORT PcbCamPopViewWindow : public QFrame { Q_OBJECT friend class PcbCamCanvas; public: - explicit PcbCamPopViewWindow(const QRectF &iSourceRect, const QRect &iTargetRect, titan::PcbCamCanvas *iCanvas); + explicit PcbCamPopViewWindow(const QRectF &iSourceRect, const QRect &iTargetRect, PcbCamCanvas *iCanvas); ~PcbCamPopViewWindow(); void setSourceRect(const QRectF &iSourceRect); QRectF sourceRect() const; @@ -54,6 +56,5 @@ private: }; -TITAN_END_NAMESPACE #endif // TITAN_PCBCAM_POPVIEWWINDOW_H diff --git a/pyside_config.py b/pyside_config.py index 973410100258e13c1fd8d2fa822b7a1b407a0022..eb15ef91efdd35ea4932c0b1d219a494dc7137a9 100644 --- a/pyside_config.py +++ b/pyside_config.py @@ -1,125 +1,100 @@ -############################################################################# -## -## Copyright (C) 2019 The Qt Company Ltd. -## Contact: http://www.qt.io/licensing/ -## -## This file is part of the Qt for Python examples of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:BSD$ -## You may use this file under the terms of the BSD license as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# - -import os, glob, re, sys from distutils import sysconfig +from enum import Enum +import glob +import os +import re +import sys -generic_error = (' Did you forget to activate your virtualenv? Or perhaps' - ' you forgot to build / install PySide2 into your currently active Python' + +PYSIDE = 'pyside6' +PYSIDE_MODULE = 'PySide6' +SHIBOKEN = 'shiboken6' + +class Package(Enum): + SHIBOKEN_MODULE = 1 + SHIBOKEN_GENERATOR = 2 + PYSIDE_MODULE = 3 + + +generic_error = ('Did you forget to activate your virtualenv? Or perhaps' + f' you forgot to build / install {PYSIDE_MODULE} into your currently active Python' ' environment?') -pyside2_error = 'Unable to locate PySide2.' + generic_error -shiboken2_module_error = 'Unable to locate shiboken2-module.' + generic_error -shiboken2_generator_error = 'Unable to locate shiboken2-generator.' + generic_error -pyside2_libs_error = 'Unable to locate the PySide2 shared libraries.' + generic_error +pyside_error = f'Unable to locate {PYSIDE_MODULE}. {generic_error}' +shiboken_module_error = f'Unable to locate {SHIBOKEN}-module. {generic_error}' +shiboken_generator_error = f'Unable to locate shiboken-generator. {generic_error}' +pyside_libs_error = f'Unable to locate the PySide shared libraries. {generic_error}' python_link_error = 'Unable to locate the Python library for linking.' python_include_error = 'Unable to locate the Python include headers directory.' options = [] # option, function, error, description -options.append(("--shiboken2-module-path", - lambda: find_shiboken2_module(), - shiboken2_module_error, - "Print shiboken2 module location")) -options.append(("--shiboken2-generator-path", - lambda: find_shiboken2_generator(), - shiboken2_generator_error, - "Print shiboken2 generator location")) -options.append(("--pyside2-path", lambda: find_pyside2(), pyside2_error, - "Print PySide2 location")) +options.append(("--shiboken-module-path", + lambda: find_shiboken_module(), + shiboken_module_error, + "Print shiboken module location")) +options.append(("--shiboken-generator-path", + lambda: find_shiboken_generator(), + shiboken_generator_error, + "Print shiboken generator location")) +options.append(("--pyside-path", lambda: find_pyside(), pyside_error, + f"Print {PYSIDE_MODULE} location")) options.append(("--python-include-path", lambda: get_python_include_path(), python_include_error, "Print Python include path")) -options.append(("--shiboken2-generator-include-path", - lambda: get_package_include_path(Package.shiboken2_generator), - pyside2_error, - "Print shiboken2 generator include paths")) -options.append(("--pyside2-include-path", - lambda: get_package_include_path(Package.pyside2), - pyside2_error, - "Print PySide2 include paths")) +options.append(("--shiboken-generator-include-path", + lambda: get_package_include_path(Package.SHIBOKEN_GENERATOR), + pyside_error, + "Print shiboken generator include paths")) +options.append(("--pyside-include-path", + lambda: get_package_include_path(Package.PYSIDE_MODULE), + pyside_error, + "Print PySide6 include paths")) options.append(("--python-link-flags-qmake", lambda: python_link_flags_qmake(), python_link_error, "Print python link flags for qmake")) options.append(("--python-link-flags-cmake", lambda: python_link_flags_cmake(), python_link_error, "Print python link flags for cmake")) -options.append(("--shiboken2-module-qmake-lflags", - lambda: get_package_qmake_lflags(Package.shiboken2_module), pyside2_error, - "Print shiboken2 shared library link flags for qmake")) -options.append(("--pyside2-qmake-lflags", - lambda: get_package_qmake_lflags(Package.pyside2), pyside2_error, - "Print PySide2 shared library link flags for qmake")) - -options.append(("--shiboken2-module-shared-libraries-qmake", - lambda: get_shared_libraries_qmake(Package.shiboken2_module), pyside2_libs_error, - "Print paths of shiboken2 shared libraries (.so's, .dylib's, .dll's) for qmake")) -options.append(("--shiboken2-module-shared-libraries-cmake", - lambda: get_shared_libraries_cmake(Package.shiboken2_module), pyside2_libs_error, - "Print paths of shiboken2 shared libraries (.so's, .dylib's, .dll's) for cmake")) - -options.append(("--pyside2-shared-libraries-qmake", - lambda: get_shared_libraries_qmake(Package.pyside2), pyside2_libs_error, - "Print paths of PySide2 shared libraries (.so's, .dylib's, .dll's) for qmake")) -options.append(("--pyside2-shared-libraries-cmake", - lambda: get_shared_libraries_cmake(Package.pyside2), pyside2_libs_error, - "Print paths of PySide2 shared libraries (.so's, .dylib's, .dll's) for cmake")) +options.append(("--shiboken-module-qmake-lflags", + lambda: get_package_qmake_lflags(Package.SHIBOKEN_MODULE), pyside_error, + "Print shiboken6 shared library link flags for qmake")) +options.append(("--pyside-qmake-lflags", + lambda: get_package_qmake_lflags(Package.PYSIDE_MODULE), pyside_error, + "Print PySide6 shared library link flags for qmake")) + +options.append(("--shiboken-module-shared-libraries-qmake", + lambda: get_shared_libraries_qmake(Package.SHIBOKEN_MODULE), pyside_libs_error, + "Print paths of shiboken shared libraries (.so's, .dylib's, .dll's) for qmake")) +options.append(("--shiboken-module-shared-libraries-cmake", + lambda: get_shared_libraries_cmake(Package.SHIBOKEN_MODULE), pyside_libs_error, + "Print paths of shiboken shared libraries (.so's, .dylib's, .dll's) for cmake")) + +options.append(("--pyside-shared-libraries-qmake", + lambda: get_shared_libraries_qmake(Package.PYSIDE_MODULE), pyside_libs_error, + "Print paths of f{PYSIDE_MODULE} shared libraries (.so's, .dylib's, .dll's) for qmake")) +options.append(("--pyside-shared-libraries-cmake", + lambda: get_shared_libraries_cmake(Package.PYSIDE_MODULE), pyside_libs_error, + f"Print paths of {PYSIDE_MODULE} shared libraries (.so's, .dylib's, .dll's) for cmake")) options_usage = '' for i, (flag, _, _, description) in enumerate(options): - options_usage += ' {:<45} {}'.format(flag, description) + options_usage += f' {flag:<45} {description}' if i < len(options) - 1: options_usage += '\n' -usage = """ -Utility to determine include/link options of shiboken2/PySide2 and Python for qmake/CMake projects -that would like to embed or build custom shiboken2/PySide2 bindings. +usage = f""" +Utility to determine include/link options of shiboken/PySide and Python for qmake/CMake projects +that would like to embed or build custom shiboken/PySide bindings. -Usage: pyside2_config.py [option] +Usage: pyside_config.py [option] Options: -{} +{options_usage} -a Print all options and their values --help/-h Print this help -""".format(options_usage) +""" option = sys.argv[1] if len(sys.argv) == 2 else '-a' if option == '-h' or option == '--help': @@ -127,12 +102,6 @@ if option == '-h' or option == '--help': sys.exit(0) -class Package(object): - shiboken2_module = 1 - shiboken2_generator = 2 - pyside2 = 3 - - def clean_path(path): return path if sys.platform != 'win32' else path.replace('\\', '/') @@ -148,15 +117,8 @@ def shared_library_suffix(): def import_suffixes(): - if (sys.version_info >= (3, 4)): - import importlib.machinery - return importlib.machinery.EXTENSION_SUFFIXES - else: - import imp - result = [] - for t in imp.get_suffixes(): - result.append(t[0]) - return result + import importlib.machinery + return importlib.machinery.EXTENSION_SUFFIXES def is_debug(): @@ -172,7 +134,7 @@ def shared_library_glob_pattern(): def filter_shared_libraries(libs_list): def predicate(lib_name): basename = os.path.basename(lib_name) - if 'shiboken' in basename or 'pyside2' in basename: + if 'shiboken' in basename or 'pyside6' in basename: return True return False result = [lib for lib in libs_list if predicate(lib)] @@ -196,26 +158,26 @@ def link_option(lib): return link -# Locate PySide2 via sys.path package path. -def find_pyside2(): - return find_package_path("PySide2") +# Locate PySide6 via sys.path package path. +def find_pyside(): + return find_package_path(PYSIDE_MODULE) -def find_shiboken2_module(): - return find_package_path("shiboken2") +def find_shiboken_module(): + return find_package_path(SHIBOKEN) -def find_shiboken2_generator(): - return find_package_path("shiboken2_generator") +def find_shiboken_generator(): + return find_package_path(f"{SHIBOKEN}_generator") def find_package(which_package): - if which_package == Package.shiboken2_module: - return find_shiboken2_module() - if which_package == Package.shiboken2_generator: - return find_shiboken2_generator() - if which_package == Package.pyside2: - return find_pyside2() + if which_package == Package.SHIBOKEN_MODULE: + return find_shiboken_module() + if which_package == Package.SHIBOKEN_GENERATOR: + return find_shiboken_generator() + if which_package == Package.PYSIDE_MODULE: + return find_pyside() return None @@ -228,7 +190,7 @@ def find_package_path(dir_name): return None -# Return version as "3.5" +# Return version as "3.6" def python_version(): return str(sys.version_info[0]) + '.' + str(sys.version_info[1]) @@ -247,20 +209,24 @@ def python_link_flags_qmake(): for d in libdir.split("\\"): if " " in d: libdir = libdir.replace(d, d.split(" ")[0][:-1]+"~1") - return '-L{} -l{}'.format(libdir, flags['lib']) + lib_flags = flags['lib'] + return f'-L{libdir} -l{lib_flags}' elif sys.platform == 'darwin': - return '-L{} -l{}'.format(flags['libdir'], flags['lib']) - + libdir = flags['libdir'] + lib_flags = flags['lib'] + return f'-L{libdir} -l{lib_flags}' else: # Linux and anything else - return '-L{} -l{}'.format(flags['libdir'], flags['lib']) + libdir = flags['libdir'] + lib_flags = flags['lib'] + return f'-L{libdir} -l{lib_flags}' def python_link_flags_cmake(): flags = python_link_data() libdir = flags['libdir'] lib = re.sub(r'.dll$', '.lib', flags['lib']) - return '{};{}'.format(libdir, lib) + return f'{libdir};{lib}' def python_link_data(): @@ -276,18 +242,14 @@ def python_link_data(): flags['libdir'] = libdir if sys.platform == 'win32': suffix = '_d' if is_debug() else '' - flags['lib'] = 'python{}{}'.format(version_no_dots, suffix) + flags['lib'] = f'python{version_no_dots}{suffix}' elif sys.platform == 'darwin': - flags['lib'] = 'python{}'.format(version) + flags['lib'] = f'python{version}' # Linux and anything else else: - if sys.version_info[0] < 3: - suffix = '_d' if is_debug() else '' - flags['lib'] = 'python{}{}'.format(version, suffix) - else: - flags['lib'] = 'python{}{}'.format(version, sys.abiflags) + flags['lib'] = f'python{version}{sys.abiflags}' return flags @@ -297,7 +259,7 @@ def get_package_include_path(which_package): if package_path is None: return None - includes = "{0}/include".format(package_path) + includes = f"{package_path}/include" return includes @@ -307,7 +269,7 @@ def get_package_qmake_lflags(which_package): if package_path is None: return None - link = "-L{}".format(package_path) + link = f"-L{package_path}" glob_result = glob.glob(os.path.join(package_path, shared_library_glob_pattern())) for lib in filter_shared_libraries(glob_result): link += ' ' @@ -368,5 +330,5 @@ for argument, handler, error, _ in options: line = handler_result if print_all: - line = "{:<40}: ".format(argument) + line + line = f"{argument:<40}: {line}" print(line) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..ec3416060c30011b9cc0d8b112dd615c85937960 --- /dev/null +++ b/setup.py @@ -0,0 +1,139 @@ +import os +import platform +import subprocess +import shutil +from pathlib import Path +from setuptools import setup, Extension, find_namespace_packages +from setuptools.command.build_ext import build_ext +from PySide6.support.generate_pyi import generate_all_pyi + + +# ---- PROJECT SETTING ---------- # +NAMESPACE = "timp" +PROJECT = "pcbcam" +VERSION = "1.0.0" +DESCRIPTION = "pcbcam lib" + +# ---- END OF PROJECT SETTING ----# + + +class CMakeExtension(Extension): + """ CMake编译扩展类 """ + + def __init__(self, name: str, namespace: str = "", sourcedir: str = ""): + Extension.__init__(self, name, sources=[]) + self.namespace = namespace + self.sourcedir = os.path.abspath(sourcedir) + + +class CMakeBuild(build_ext): + """ CMake编译方法类 """ + + def build_extension(self, ext): + # setuptools 打包文件时创建的临时路径 + py_build_dir = Path(os.path.abspath(self.build_lib)) + if ext.namespace: + py_build_dir = py_build_dir.joinpath(ext.namespace) + py_build_dir = py_build_dir.joinpath(ext.name) + + # c++æºç 所在路径,在ä¸åŒç³»ç»Ÿä¸‹ä½¿ç”¨ä¸åŒçš„编译目录 + build_temp = Path(ext.sourcedir).joinpath('../build') + if not build_temp.exists(): + os.makedirs(build_temp) + + # è¿½åŠ QT路径至PATH环境å˜ä¸, 以便CMakeçš„FindPackage能够找到Qt相关ä¾èµ– + qt_dir = self.get_qt_dir() + qt_bin = os.path.join(qt_dir, "bin") + path_sep = ';' if platform.system() == "Windows" else ':' + env_path = qt_bin + path_sep + os.environ.get("PATH") + os.environ.update(PATH=env_path) + + # Windows下åˆå§‹åŒ–Visual Studio C++编译环境 + self.init_msvc_env() + + # 执行CMake进行编译 + subprocess.check_call('cmake .. -B. -G Ninja -D CMAKE_BUILD_TYPE=Release', cwd=build_temp) + subprocess.check_call(['ninja'], cwd=build_temp) + subprocess.check_call(['ninja', 'install'], cwd=build_temp) + + # æ‹·è´åЍæ€åº“至打包目录 + # libray_files = [] + # if platform.system() == "Windows": + # libray_files.append("{}.pyd".format(ext.name)) + # libray_files.append("lib{}.dll".format(ext.name)) + # elif platform.system() == "Darwin": + # libray_files.append("{}.so".format(ext.name)) + # libray_files.append("lib{}.dylib".format(ext.name)) + # else: + # libray_files.append("{}.so".format(ext.name)) + # libray_files.append("lib{}.so".format(ext.name)) + + # print('copying dynamic library file') + # pak_dir = Path(ext.sourcedir).parent.joinpath(ext.namespace, ext.name) + # for lib in libray_files: + # src_file = pak_dir.joinpath(lib) + # print(f'copying {src_file} -> {py_build_dir}') + # shutil.copy(src_file, py_build_dir) + + def get_qt_dir(self) -> str: + """ 获å–QT路径 """ + + timp_qt_dir = '' + if 'TIMP_QT_DIR' in os.environ: + timp_qt_dir = os.environ.get('TIMP_QT_DIR') + elif 'QT6_DIR' in os.environ: + timp_qt_dir = os.environ.get('QT6_DIR') + elif 'QT_DIR' in os.environ: + timp_qt_dir = os.environ.get('QT_DIR') + + if not timp_qt_dir: + raise Exception('Please set TIMP_QT_DIR into environment') + + return timp_qt_dir + + def init_msvc_env(self) -> None: + """ åˆå§‹åŒ–Visual Studio C++ 编译环境""" + + if platform.system() != "Windows": + return + + vcvar = '' + qt_dir = self.get_qt_dir() + if 'msvc2015' in qt_dir: + vcvar = '"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat" amd64' + elif 'msvc2019' in qt_dir: + vcvar = '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"' + + pipe = os.popen("{0} && {1}".format(vcvar, 'set')) + output = pipe.read() + pipe.close() + env = dict((e[0].upper(), e[1]) for e in [p.rstrip().split("=", 1) for p in output.split('\n')] if len(e) == 2) + os.environ.update(env) + + +setup( + name="{}.{}".format(NAMESPACE, PROJECT), + version=VERSION, + author="toplinker", + author_email="service@topibd.com", + description=DESCRIPTION, + long_description=DESCRIPTION, + ext_modules=[CMakeExtension(name=PROJECT, namespace=NAMESPACE, sourcedir="lib")], + cmdclass={"build_ext": CMakeBuild}, + package_dir={'': 'build'}, + packages=find_namespace_packages(where='build', include=["{}.{}".format(NAMESPACE, PROJECT)]), + python_requires='>=3.8', + install_requires=[ + 'PySide6', + 'shiboken6', + ], + setup_requires=[ + 'PySide6', + 'shiboken6', + 'shiboken6_generator', + ], + tests_require=[], + extras_require={}, + dependency_links=["http://nexus.topibd.net/repository/pypi-public/simple"], + zip_safe=False, +)