Sketcher: App - Clang-format
This commit is contained in:
committed by
abdullahtahiriyo
parent
c33cdcd68a
commit
987b4bda2a
@@ -32,31 +32,32 @@
|
||||
#include "SketchObjectSF.h"
|
||||
|
||||
|
||||
namespace Sketcher {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
namespace Sketcher
|
||||
{
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("Sketcher")
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("Sketcher")
|
||||
{
|
||||
add_varargs_method("open",&Module::open
|
||||
);
|
||||
add_varargs_method("insert",&Module::insert
|
||||
);
|
||||
initialize("This module is the Sketcher module."); // register with Python
|
||||
add_varargs_method("open", &Module::open);
|
||||
add_varargs_method("insert", &Module::insert);
|
||||
initialize("This module is the Sketcher module.");// register with Python
|
||||
}
|
||||
|
||||
~Module() override {}
|
||||
~Module() override
|
||||
{}
|
||||
|
||||
private:
|
||||
Py::Object open(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name))
|
||||
throw Py::Exception();
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
//Base::Console().Log("Open in Part with %s",Name);
|
||||
// Base::Console().Log("Open in Part with %s",Name);
|
||||
Base::FileInfo file(EncodedName.c_str());
|
||||
|
||||
// extract extension
|
||||
@@ -64,33 +65,34 @@ private:
|
||||
throw Py::RuntimeError("No file extension");
|
||||
|
||||
throw Py::RuntimeError("Unknown file extension");
|
||||
//return Py::None();
|
||||
// return Py::None();
|
||||
}
|
||||
|
||||
Py::Object insert(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
const char* DocName;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "ets","utf-8",&Name,&DocName))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "ets", "utf-8", &Name, &DocName))
|
||||
throw Py::Exception();
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
try {
|
||||
//Base::Console().Log("Insert in Part with %s",Name);
|
||||
// Base::Console().Log("Insert in Part with %s",Name);
|
||||
Base::FileInfo file(EncodedName.c_str());
|
||||
|
||||
// extract extension
|
||||
if (file.extension().empty())
|
||||
throw Py::RuntimeError("No file extension");
|
||||
|
||||
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
|
||||
App::Document* pcDoc = App::GetApplication().getDocument(DocName);
|
||||
if (!pcDoc) {
|
||||
pcDoc = App::GetApplication().newDocument(DocName);
|
||||
}
|
||||
|
||||
if (file.hasExtension("skf")) {
|
||||
Sketcher::SketchObjectSF *pcFeature = static_cast<Sketcher::SketchObjectSF *>(pcDoc->addObject("Sketcher::SketchObjectSF",file.fileNamePure().c_str()));
|
||||
Sketcher::SketchObjectSF* pcFeature = static_cast<Sketcher::SketchObjectSF*>(
|
||||
pcDoc->addObject("Sketcher::SketchObjectSF", file.fileNamePure().c_str()));
|
||||
pcFeature->SketchFlatFile.setValue(EncodedName.c_str());
|
||||
|
||||
pcDoc->recompute();
|
||||
@@ -113,4 +115,4 @@ PyObject* initModule()
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
} // namespace Sketcher
|
||||
}// namespace Sketcher
|
||||
|
||||
Reference in New Issue
Block a user