FreeCAD WebAssembly development snapshot
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
This commit is contained in:
1558
src/Mod/Cloud/App/AppCloud.cpp
Normal file
1558
src/Mod/Cloud/App/AppCloud.cpp
Normal file
File diff suppressed because it is too large
Load Diff
270
src/Mod/Cloud/App/AppCloud.h
Normal file
270
src/Mod/Cloud/App/AppCloud.h
Normal file
@@ -0,0 +1,270 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <App/Document.h>
|
||||
|
||||
#include <Base/Base64.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Writer.h>
|
||||
|
||||
#include <Mod/Cloud/CloudGlobal.h>
|
||||
|
||||
#include <xercesc/dom/DOM.hpp>
|
||||
#include <xercesc/framework/MemBufInputSource.hpp>
|
||||
#include <xercesc/framework/XMLPScanToken.hpp>
|
||||
#include <xercesc/parsers/XercesDOMParser.hpp>
|
||||
#include <xercesc/sax/HandlerBase.hpp>
|
||||
#include <xercesc/sax2/Attributes.hpp>
|
||||
#include <xercesc/sax2/DefaultHandler.hpp>
|
||||
|
||||
|
||||
XERCES_CPP_NAMESPACE_BEGIN
|
||||
class DOMNode;
|
||||
class DOMText;
|
||||
XERCES_CPP_NAMESPACE_END
|
||||
|
||||
namespace Cloud
|
||||
{
|
||||
|
||||
struct AmzData
|
||||
{
|
||||
std::string digest;
|
||||
char dateFormatted[256];
|
||||
char ContentType[256];
|
||||
char Host[256];
|
||||
char* MD5;
|
||||
};
|
||||
|
||||
struct AmzDatav4
|
||||
{
|
||||
std::string digest;
|
||||
char dateFormattedS[256];
|
||||
char dateFormattedD[256];
|
||||
char ContentType[256];
|
||||
char Host[256];
|
||||
std::string Region;
|
||||
char* MD5;
|
||||
char* SHA256Sum;
|
||||
};
|
||||
|
||||
std::string getHexValue(unsigned char* input, unsigned int HMACLength);
|
||||
void eraseSubStr(std::string& Str, const std::string& toErase);
|
||||
size_t CurlWrite_CallbackFunc_StdString(void* contents, size_t size, size_t nmemb, std::string* s);
|
||||
struct AmzData* ComputeDigestAmzS3v2(
|
||||
char* operation,
|
||||
char* data_type,
|
||||
const char* target,
|
||||
const char* Secret,
|
||||
const char* ptr,
|
||||
long size
|
||||
);
|
||||
struct AmzDatav4* ComputeDigestAmzS3v4(
|
||||
char* operation,
|
||||
const char* server,
|
||||
char* data_type,
|
||||
const char* target,
|
||||
const char* Secret,
|
||||
const char* ptr,
|
||||
long size,
|
||||
char* parameters,
|
||||
std::string Region
|
||||
);
|
||||
struct curl_slist* BuildHeaderAmzS3v2(
|
||||
const char* URL,
|
||||
const char* TCPPort,
|
||||
const char* PublicKey,
|
||||
struct AmzData* Data
|
||||
);
|
||||
struct curl_slist* BuildHeaderAmzS3v4(const char* URL, const char* PublicKey, struct AmzDatav4* Data);
|
||||
char* MD5Sum(const char* ptr, long size);
|
||||
char* SHA256Sum(const char* ptr, long size);
|
||||
|
||||
class CloudAppExport CloudReader
|
||||
{
|
||||
public:
|
||||
CloudReader(
|
||||
const char* URL,
|
||||
const char* AccessKey,
|
||||
const char* SecretKey,
|
||||
const char* TCPPort,
|
||||
const char* Bucket,
|
||||
std::string ProtocolVersion,
|
||||
std::string Region
|
||||
);
|
||||
virtual ~CloudReader();
|
||||
int file = 0;
|
||||
int continuation = 0;
|
||||
int truncated = 0;
|
||||
|
||||
struct FileEntry
|
||||
{
|
||||
char FileName[1024];
|
||||
std::stringstream FileStream;
|
||||
int touch = 0;
|
||||
};
|
||||
void checkText(XERCES_CPP_NAMESPACE_QUALIFIER DOMText* text);
|
||||
void checkXML(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* node);
|
||||
void checkElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* element);
|
||||
void addFile(struct Cloud::CloudReader::FileEntry* new_entry);
|
||||
struct FileEntry* GetEntry(std::string FileName);
|
||||
void DownloadFile(Cloud::CloudReader::FileEntry* entry);
|
||||
int isTouched(std::string FileName);
|
||||
|
||||
protected:
|
||||
std::list<Cloud::CloudReader::FileEntry*> FileList;
|
||||
char* NextFileName;
|
||||
const char* URL;
|
||||
const char* TCPPort;
|
||||
const char* TokenAuth;
|
||||
const char* TokenSecret;
|
||||
const char* Bucket;
|
||||
std::string ProtocolVersion;
|
||||
std::string Region;
|
||||
};
|
||||
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("Cloud")
|
||||
{
|
||||
add_varargs_method(
|
||||
"URL",
|
||||
&Module::sCloudURL,
|
||||
"URL(string) -- Connect to a Cloud Storage service."
|
||||
);
|
||||
|
||||
add_varargs_method(
|
||||
"TokenAuth",
|
||||
&Module::sCloudTokenAuth,
|
||||
"TokenAuth(string) -- Token Authorization string."
|
||||
);
|
||||
|
||||
add_varargs_method(
|
||||
"TokenSecret",
|
||||
&Module::sCloudTokenSecret,
|
||||
"TokenSecret(string) -- Token Secret string."
|
||||
);
|
||||
|
||||
add_varargs_method("TCPPort", &Module::sCloudTCPPort, "TCPPort(string) -- Port number.");
|
||||
|
||||
add_varargs_method(
|
||||
"Save",
|
||||
&Module::sCloudSave,
|
||||
"Save(string) -- Save the active document to the Cloud."
|
||||
);
|
||||
|
||||
add_varargs_method(
|
||||
"Restore",
|
||||
&Module::sCloudRestore,
|
||||
"Restore(string) -- Restore to the active document from the Cloud."
|
||||
);
|
||||
|
||||
add_varargs_method(
|
||||
"ProtocolVersion",
|
||||
&Module::sCloudProtocolVersion,
|
||||
"ProtocolVersion(string) -- Specify Amazon s3 protocol version (2 or 4)"
|
||||
);
|
||||
add_varargs_method("Region", &Module::sCloudRegion, "Region(string) -- Specify Amazon s3 Region");
|
||||
|
||||
initialize("This module is the Cloud module."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~Module()
|
||||
{}
|
||||
|
||||
App::PropertyString URL;
|
||||
App::PropertyString TCPPort;
|
||||
App::PropertyString TokenAuth;
|
||||
App::PropertyString TokenSecret;
|
||||
App::PropertyString ProtocolVersion;
|
||||
App::PropertyString Region;
|
||||
bool cloudSave(const char* BucketName);
|
||||
bool cloudRestore(const char* BucketName);
|
||||
void LinkXSetValue(std::string filename);
|
||||
|
||||
private:
|
||||
Py::Object sCloudURL(const Py::Tuple& args);
|
||||
Py::Object sCloudTokenAuth(const Py::Tuple& args);
|
||||
Py::Object sCloudTokenSecret(const Py::Tuple& args);
|
||||
Py::Object sCloudTCPPort(const Py::Tuple& args);
|
||||
Py::Object sCloudSave(const Py::Tuple& args);
|
||||
Py::Object sCloudRestore(const Py::Tuple& args);
|
||||
Py::Object sCloudProtocolVersion(const Py::Tuple& args);
|
||||
Py::Object sCloudRegion(const Py::Tuple& args);
|
||||
};
|
||||
|
||||
PyObject* initModule()
|
||||
{
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
|
||||
// This class is writing files to an S3 cloud storage class
|
||||
|
||||
class CloudAppExport CloudWriter: public Base::Writer
|
||||
{
|
||||
public:
|
||||
int print = 0;
|
||||
char errorCode[1024] = "";
|
||||
CloudWriter(
|
||||
const char* URL,
|
||||
const char* TokenAuth,
|
||||
const char* TokenSecret,
|
||||
const char* TCPPort,
|
||||
const char* Bucket,
|
||||
std::string ProtocolVersion,
|
||||
std::string Region
|
||||
);
|
||||
virtual ~CloudWriter();
|
||||
void pushCloud(const char* FileName, const char* data, long size);
|
||||
void putNextEntry(const char* file);
|
||||
void createBucket();
|
||||
virtual void writeFiles(void);
|
||||
|
||||
virtual std::ostream& Stream(void)
|
||||
{
|
||||
return FileStream;
|
||||
}
|
||||
virtual bool shouldWrite(const std::string& name, const Base::Persistence* Object) const;
|
||||
void checkText(XERCES_CPP_NAMESPACE_QUALIFIER DOMText* text);
|
||||
void checkXML(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* node);
|
||||
void checkElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* element);
|
||||
|
||||
protected:
|
||||
std::string FileName;
|
||||
const char* URL;
|
||||
const char* TCPPort;
|
||||
const char* TokenAuth;
|
||||
const char* TokenSecret;
|
||||
const char* Bucket;
|
||||
std::string ProtocolVersion;
|
||||
std::string Region;
|
||||
std::stringstream FileStream;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Cloud
|
||||
|
||||
void readFiles(Cloud::CloudReader reader, Base::XMLReader* xmlreader);
|
||||
40
src/Mod/Cloud/App/CMakeLists.txt
Normal file
40
src/Mod/Cloud/App/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENSSL_CFLAGS}")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${CURL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(Cloud_LIBS
|
||||
FreeCADApp
|
||||
${OPENSSL_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
${XercesC_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
||||
SET(Cloud_SRCS
|
||||
AppCloud.cpp
|
||||
PreCompiled.h
|
||||
)
|
||||
|
||||
add_library(Cloud SHARED ${Cloud_SRCS})
|
||||
target_link_libraries(Cloud ${Cloud_LIBS})
|
||||
|
||||
if(FREECAD_USE_PCH)
|
||||
target_precompile_headers(Cloud PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
|
||||
)
|
||||
endif(FREECAD_USE_PCH)
|
||||
|
||||
|
||||
SET_BIN_DIR(Cloud Cloud /Mod/Cloud)
|
||||
SET_PYTHON_PREFIX_SUFFIX(Cloud)
|
||||
|
||||
install(TARGETS Cloud DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
48
src/Mod/Cloud/App/PreCompiled.h
Normal file
48
src/Mod/Cloud/App/PreCompiled.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
|
||||
// standard
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
// STL
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Xerces
|
||||
#include <xercesc/util/XercesDefs.hpp>
|
||||
93
src/Mod/Cloud/CMakeLists.txt
Normal file
93
src/Mod/Cloud/CMakeLists.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#----------------------------- Control certificate validation ------------
|
||||
option(ALLOW_SELF_SIGNED_CERTIFICATE "Allow self signed certificate" OFF)
|
||||
if (ALLOW_SELF_SIGNED_CERTIFICATE)
|
||||
add_compile_options("-DALLOW_SELF_SIGNED_CERTIFICATE")
|
||||
endif ()
|
||||
#------------------------------ OpenSSL and CURL -------------------------
|
||||
if (APPLE)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(OPENSSL REQUIRED openssl)
|
||||
set (OPENSSL_LIBRARIES ${OPENSSL_LINK_LIBRARIES})
|
||||
elseif(WIN32 AND LIBPACK_FOUND)
|
||||
SET( OPENSSL_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include)
|
||||
SET( OPENSSL_LIBRARIES
|
||||
optimized ${FREECAD_LIBPACK_DIR}/lib/openssl.lib debug ${FREECAD_LIBPACK_DIR}/lib/openssld.lib
|
||||
optimized ${FREECAD_LIBPACK_DIR}/lib/libssl.lib debug ${FREECAD_LIBPACK_DIR}/lib/libssld.lib
|
||||
optimized ${FREECAD_LIBPACK_DIR}/lib/libcrypto.lib debug ${FREECAD_LIBPACK_DIR}/lib/libcryptod.lib)
|
||||
if( EXISTS ${FREECAD_LIBPACK_DIR}/lib/openssl.lib)
|
||||
SET( OPENSSL_FOUND True)
|
||||
else()
|
||||
SET( OPENSSL_FOUND False)
|
||||
message( FATAL_ERROR "openssl not found!" )
|
||||
endif(EXISTS ${FREECAD_LIBPACK_DIR}/lib/openssl.lib)
|
||||
|
||||
if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
|
||||
REGEX "OPENSSL_VERSION_STR")
|
||||
string(REGEX MATCH "\".*"
|
||||
openssl_version_str ${openssl_version_str})
|
||||
string(REPLACE "\"" "" openssl_version_str ${openssl_version_str})
|
||||
set(OPENSSL_VERSION ${openssl_version_str})
|
||||
endif ()
|
||||
else()
|
||||
find_package(OpenSSL REQUIRED)
|
||||
endif(APPLE)
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
message(STATUS "openssl-${OPENSSL_VERSION} has been found\n")
|
||||
else()
|
||||
message( FATAL_ERROR "openssl not found!" )
|
||||
endif(OPENSSL_FOUND)
|
||||
|
||||
IF(WIN32)
|
||||
SET( CURL_FOUND True)
|
||||
SET( CURL_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include)
|
||||
SET( CURL_LIBRARIES
|
||||
optimized ${FREECAD_LIBPACK_DIR}/lib/libcurl.lib debug ${FREECAD_LIBPACK_DIR}/lib/libcurl_debug.lib)
|
||||
if( EXISTS ${FREECAD_LIBPACK_DIR}/lib/libcurl.lib)
|
||||
SET( CURL_FOUND True)
|
||||
else()
|
||||
SET( CURL_FOUND False)
|
||||
message( FATAL_ERROR "curl not found!" )
|
||||
endif(EXISTS ${FREECAD_LIBPACK_DIR}/lib/libcurl.lib)
|
||||
ELSE()
|
||||
find_package(CURL REQUIRED)
|
||||
ENDIF(WIN32)
|
||||
|
||||
|
||||
if(CURL_FOUND)
|
||||
message(STATUS "CURL has been found\n")
|
||||
endif(CURL_FOUND)
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
add_subdirectory(App)
|
||||
if(BUILD_GUI)
|
||||
add_subdirectory(Gui)
|
||||
endif(BUILD_GUI)
|
||||
|
||||
set(Cloud_Scripts
|
||||
Init.py
|
||||
)
|
||||
|
||||
if(BUILD_GUI)
|
||||
list (APPEND Cloud_Scripts InitGui.py)
|
||||
endif(BUILD_GUI)
|
||||
|
||||
add_custom_target(CloudScripts ALL
|
||||
SOURCES ${Cloud_Scripts}
|
||||
)
|
||||
|
||||
fc_target_copy_resource_flat(CloudScripts
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}/Mod/Cloud
|
||||
${Cloud_Scripts}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${Cloud_Scripts}
|
||||
DESTINATION
|
||||
Mod/Cloud
|
||||
)
|
||||
2
src/Mod/Cloud/Cloud.dox
Normal file
2
src/Mod/Cloud/Cloud.dox
Normal file
@@ -0,0 +1,2 @@
|
||||
/** \defgroup TEMPLATE Cloud
|
||||
* \ingroup WORKBENCHES */
|
||||
44
src/Mod/Cloud/CloudGlobal.h
Normal file
44
src/Mod/Cloud/CloudGlobal.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FCGlobal.h>
|
||||
|
||||
// Cloud
|
||||
#ifndef CloudAppExport
|
||||
# ifdef CloudApp_EXPORTS
|
||||
# define CloudAppExport FREECAD_DECL_EXPORT
|
||||
# else
|
||||
# define CloudAppExport FREECAD_DECL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Cloud
|
||||
#ifndef CloudGuiExport
|
||||
# ifdef CloudGui_EXPORTS
|
||||
# define CloudGuiExport FREECAD_DECL_EXPORT
|
||||
# else
|
||||
# define CloudGuiExport FREECAD_DECL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
80
src/Mod/Cloud/Gui/AppCloudGui.cpp
Normal file
80
src/Mod/Cloud/Gui/AppCloudGui.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include "Workbench.h"
|
||||
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreateCloudCommands(void);
|
||||
|
||||
|
||||
namespace CloudGui
|
||||
{
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("CloudGui")
|
||||
{
|
||||
initialize("This module is the CloudGui module."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~Module()
|
||||
{}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
PyObject* initModule()
|
||||
{
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
} // namespace CloudGui
|
||||
|
||||
|
||||
/* Python entry */
|
||||
PyMOD_INIT_FUNC(CloudGui)
|
||||
{
|
||||
if (!Gui::Application::Instance) {
|
||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||
PyMOD_Return(nullptr);
|
||||
}
|
||||
|
||||
// instantiating the commands
|
||||
CreateCloudCommands();
|
||||
CloudGui::Workbench::init();
|
||||
|
||||
// ADD YOUR CODE HERE
|
||||
//
|
||||
//
|
||||
PyObject* mod = CloudGui::initModule();
|
||||
Base::Console().log("Loading GUI of Cloud module... done\n");
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
43
src/Mod/Cloud/Gui/CMakeLists.txt
Normal file
43
src/Mod/Cloud/Gui/CMakeLists.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
set(CloudGui_LIBS
|
||||
Cloud
|
||||
FreeCADGui
|
||||
)
|
||||
|
||||
qt_add_resources(Cloud_QRC_SRCS Resources/Cloud.qrc)
|
||||
|
||||
SET(CloudGui_SRCS
|
||||
${Cloud_QRC_SRCS}
|
||||
AppCloudGui.cpp
|
||||
Command.cpp
|
||||
PreCompiled.h
|
||||
Workbench.cpp
|
||||
Workbench.h
|
||||
)
|
||||
|
||||
SET(Cloud_SVG
|
||||
Resources/icons/CloudWorkbench.svg
|
||||
)
|
||||
|
||||
add_library(CloudGui SHARED ${CloudGui_SRCS} ${Cloud_SVG})
|
||||
target_link_libraries(CloudGui ${CloudGui_LIBS})
|
||||
|
||||
if(FREECAD_USE_PCH)
|
||||
target_precompile_headers(CloudGui PRIVATE
|
||||
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
|
||||
)
|
||||
endif(FREECAD_USE_PCH)
|
||||
|
||||
fc_copy_sources(CloudGui "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Cloud" ${Cloud_SVG})
|
||||
|
||||
SET_BIN_DIR(CloudGui CloudGui /Mod/Cloud)
|
||||
SET_PYTHON_PREFIX_SUFFIX(CloudGui)
|
||||
|
||||
install(TARGETS CloudGui DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
INSTALL(FILES ${Cloud_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/Cloud/Resources/icons")
|
||||
59
src/Mod/Cloud/Gui/Command.cpp
Normal file
59
src/Mod/Cloud/Gui/Command.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
//===========================================================================
|
||||
// CmdCloudTest THIS IS JUST A TEST COMMAND
|
||||
//===========================================================================
|
||||
DEF_STD_CMD(CmdCloudTest)
|
||||
|
||||
CmdCloudTest::CmdCloudTest()
|
||||
: Command("Cloud_Test")
|
||||
{
|
||||
sAppModule = "Cloud";
|
||||
sGroup = QT_TR_NOOP("Cloud");
|
||||
sMenuText = QT_TR_NOOP("Hello");
|
||||
sToolTipText = QT_TR_NOOP("Cloud Test function");
|
||||
sWhatsThis = "Cloud_Test";
|
||||
sStatusTip = QT_TR_NOOP("Cloud Test function");
|
||||
sPixmap = "Test1";
|
||||
sAccel = "CTRL+H";
|
||||
}
|
||||
|
||||
void CmdCloudTest::activated(int)
|
||||
{
|
||||
Base::Console().message("Hello, World!\n");
|
||||
}
|
||||
|
||||
void CreateCloudCommands(void)
|
||||
{
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
rcCmdMgr.addCommand(new CmdCloudTest());
|
||||
}
|
||||
50
src/Mod/Cloud/Gui/PreCompiled.h
Normal file
50
src/Mod/Cloud/Gui/PreCompiled.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
// standard
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
|
||||
// STL
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
// Qt Toolkit
|
||||
#include <Gui/QtAll.h>
|
||||
4
src/Mod/Cloud/Gui/Resources/Cloud.qrc
Normal file
4
src/Mod/Cloud/Gui/Resources/Cloud.qrc
Normal file
@@ -0,0 +1,4 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
</qresource>
|
||||
</RCC>
|
||||
17
src/Mod/Cloud/Gui/Resources/icons/CloudWorkbench.svg
Normal file
17
src/Mod/Cloud/Gui/Resources/icons/CloudWorkbench.svg
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="64.000000pt" height="64.000000pt" viewBox="0 0 64.000000 64.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by Jean-Marie Verdun using potrace 1.15, written by Peter Selinger 2001-2017
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,64.000000) scale(0.100000,-0.100000)"
|
||||
fill="#4472C4" stroke="none">
|
||||
<path d="M211 523 c-21 -10 -40 -31 -51 -55 -9 -21 -34 -53 -55 -71 -34 -29
|
||||
-39 -39 -42 -88 -4 -45 -1 -60 19 -89 34 -50 70 -59 238 -59 120 -1 152 3 186
|
||||
18 99 45 96 196 -4 238 -20 8 -50 13 -67 10 -29 -5 -33 -2 -49 33 -30 68 -109
|
||||
97 -175 63z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 781 B |
60
src/Mod/Cloud/Gui/Workbench.cpp
Normal file
60
src/Mod/Cloud/Gui/Workbench.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "Workbench.h"
|
||||
#include <Gui/MenuManager.h>
|
||||
#include <Gui/ToolBarManager.h>
|
||||
|
||||
|
||||
using namespace CloudGui;
|
||||
|
||||
/// @namespace CloudGui @class Workbench
|
||||
TYPESYSTEM_SOURCE(CloudGui::Workbench, Gui::StdWorkbench)
|
||||
|
||||
Workbench::Workbench()
|
||||
{}
|
||||
|
||||
Workbench::~Workbench()
|
||||
{}
|
||||
/*
|
||||
Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
{
|
||||
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
|
||||
Gui::MenuItem* item = root->findItem( "&Windows" );
|
||||
Gui::MenuItem* test = new Gui::MenuItem;
|
||||
root->insertItem( item, test );
|
||||
test->setCommand("Cloud");
|
||||
*test << "Cloud_Test";
|
||||
return root;
|
||||
}
|
||||
|
||||
Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
{
|
||||
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
|
||||
Gui::ToolBarItem* test = new Gui::ToolBarItem(root);
|
||||
test->setCommand( "Cloud Tools" );
|
||||
*test << "Cloud_Test";
|
||||
return root;
|
||||
}
|
||||
*/
|
||||
45
src/Mod/Cloud/Gui/Workbench.h
Normal file
45
src/Mod/Cloud/Gui/Workbench.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Gui/Workbench.h>
|
||||
|
||||
namespace CloudGui
|
||||
{
|
||||
|
||||
class Workbench: public Gui::StdWorkbench
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
Workbench();
|
||||
virtual ~Workbench();
|
||||
|
||||
protected:
|
||||
// Gui::MenuItem* setupMenuBar() const;
|
||||
// Gui::ToolBarItem* setupToolBars() const;
|
||||
};
|
||||
|
||||
} // namespace CloudGui
|
||||
5
src/Mod/Cloud/Init.py
Normal file
5
src/Mod/Cloud/Init.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
# FreeCAD init script of the Cloud module
|
||||
# (c) 2001 Juergen Riegel LGPL
|
||||
# (c) 2019 Jean-Marie Verdun LGPL
|
||||
27
src/Mod/Cloud/InitGui.py
Normal file
27
src/Mod/Cloud/InitGui.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
# Cloud gui init module
|
||||
# (c) 2001 Juergen Riegel LGPL
|
||||
# (c) 2019 Jean-Marie Verdun LGPL
|
||||
|
||||
|
||||
class CloudWorkbench(Workbench):
|
||||
"Cloud workbench object"
|
||||
|
||||
def __init__(self):
|
||||
self.__class__.Icon = (
|
||||
FreeCAD.getResourceDir() + "Mod/Cloud/Resources/icons/CloudWorkbench.svg"
|
||||
)
|
||||
|
||||
MenuText = "Cloud"
|
||||
ToolTip = "Cloud workbench"
|
||||
|
||||
def Initialize(self):
|
||||
# load the module
|
||||
import CloudGui
|
||||
|
||||
def GetClassName(self):
|
||||
return "CloudGui::Workbench"
|
||||
|
||||
|
||||
Gui.addWorkbench(CloudWorkbench())
|
||||
Reference in New Issue
Block a user