+ improve whitespaces
+ fix sequence protocol and fix crash
This commit is contained in:
parent
e331bdbc5d
commit
61376ef135
|
@ -439,6 +439,7 @@ Application::Application(bool GUIenabled)
|
||||||
PythonStdin ::init_type();
|
PythonStdin ::init_type();
|
||||||
View3DInventorPy ::init_type();
|
View3DInventorPy ::init_type();
|
||||||
View3DInventorViewerPy ::init_type();
|
View3DInventorViewerPy ::init_type();
|
||||||
|
AbstractSplitViewPy ::init_type();
|
||||||
|
|
||||||
d = new ApplicationP;
|
d = new ApplicationP;
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,6 @@ public:
|
||||||
PYFUNCDEF_S(sShowDownloads);
|
PYFUNCDEF_S(sShowDownloads);
|
||||||
PYFUNCDEF_S(sShowPreferences);
|
PYFUNCDEF_S(sShowPreferences);
|
||||||
|
|
||||||
|
|
||||||
PYFUNCDEF_S(sCreateViewer);
|
PYFUNCDEF_S(sCreateViewer);
|
||||||
|
|
||||||
static PyMethodDef Methods[];
|
static PyMethodDef Methods[];
|
||||||
|
|
|
@ -1114,7 +1114,6 @@ PyObject* Application::sShowPreferences(PyObject * /*self*/, PyObject *args,PyOb
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyObject* Application::sCreateViewer(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
|
PyObject* Application::sCreateViewer(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -374,11 +374,6 @@ void AbstractSplitView::setOverrideCursor(const QCursor& aCursor)
|
||||||
|
|
||||||
PyObject *AbstractSplitView::getPyObject(void)
|
PyObject *AbstractSplitView::getPyObject(void)
|
||||||
{
|
{
|
||||||
static bool init = false;
|
|
||||||
if (!init) {
|
|
||||||
init = true;
|
|
||||||
AbstractSplitViewPy::init_type();
|
|
||||||
}
|
|
||||||
if (!_viewerPy)
|
if (!_viewerPy)
|
||||||
_viewerPy = new AbstractSplitViewPy(this);
|
_viewerPy = new AbstractSplitViewPy(this);
|
||||||
Py_INCREF(_viewerPy);
|
Py_INCREF(_viewerPy);
|
||||||
|
@ -392,7 +387,7 @@ void AbstractSplitView::setPyObject(PyObject *)
|
||||||
|
|
||||||
int AbstractSplitView::getSize()
|
int AbstractSplitView::getSize()
|
||||||
{
|
{
|
||||||
return _viewer.size();
|
return static_cast<int>(_viewer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
@ -428,7 +423,7 @@ AbstractSplitViewPy::~AbstractSplitViewPy()
|
||||||
|
|
||||||
void AbstractSplitViewPy::testExistence()
|
void AbstractSplitViewPy::testExistence()
|
||||||
{
|
{
|
||||||
if (!(_view and _view->getViewer(0)))
|
if (!(_view && _view->getViewer(0)))
|
||||||
throw Py::Exception("Object already deleted");
|
throw Py::Exception("Object already deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,6 +442,7 @@ Py::Object AbstractSplitViewPy::fitAll(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewFit", 0);
|
_view->onMsg("ViewFit", 0);
|
||||||
}
|
}
|
||||||
|
@ -467,6 +463,7 @@ Py::Object AbstractSplitViewPy::viewBottom(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewBottom", 0);
|
_view->onMsg("ViewBottom", 0);
|
||||||
}
|
}
|
||||||
|
@ -488,6 +485,7 @@ Py::Object AbstractSplitViewPy::viewFront(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewFront", 0);
|
_view->onMsg("ViewFront", 0);
|
||||||
}
|
}
|
||||||
|
@ -509,6 +507,7 @@ Py::Object AbstractSplitViewPy::viewLeft(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewLeft", 0);
|
_view->onMsg("ViewLeft", 0);
|
||||||
}
|
}
|
||||||
|
@ -530,6 +529,7 @@ Py::Object AbstractSplitViewPy::viewRear(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewRear", 0);
|
_view->onMsg("ViewRear", 0);
|
||||||
}
|
}
|
||||||
|
@ -551,6 +551,7 @@ Py::Object AbstractSplitViewPy::viewRight(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewRight", 0);
|
_view->onMsg("ViewRight", 0);
|
||||||
}
|
}
|
||||||
|
@ -572,6 +573,7 @@ Py::Object AbstractSplitViewPy::viewTop(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewTop", 0);
|
_view->onMsg("ViewTop", 0);
|
||||||
}
|
}
|
||||||
|
@ -593,6 +595,7 @@ Py::Object AbstractSplitViewPy::viewAxometric(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_view->onMsg("ViewAxo", 0);
|
_view->onMsg("ViewAxo", 0);
|
||||||
}
|
}
|
||||||
|
@ -615,8 +618,12 @@ Py::Object AbstractSplitViewPy::getViewer(const Py::Tuple& args)
|
||||||
if (!PyArg_ParseTuple(args.ptr(), "i", &viewIndex))
|
if (!PyArg_ParseTuple(args.ptr(), "i", &viewIndex))
|
||||||
throw Py::Exception();
|
throw Py::Exception();
|
||||||
testExistence();
|
testExistence();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Py::Object(_view->getViewer(viewIndex)->getPyObject());
|
Gui::View3DInventorViewer* view = _view->getViewer(viewIndex);
|
||||||
|
if (!view)
|
||||||
|
throw Py::IndexError("Index out of range");
|
||||||
|
return Py::Object(view->getPyObject());
|
||||||
}
|
}
|
||||||
catch (const Base::Exception& e) {
|
catch (const Base::Exception& e) {
|
||||||
throw Py::Exception(e.what());
|
throw Py::Exception(e.what());
|
||||||
|
@ -634,14 +641,15 @@ Py::Object AbstractSplitViewPy::getViewer(const Py::Tuple& args)
|
||||||
Py::Object AbstractSplitViewPy::sequence_item(ssize_t viewIndex)
|
Py::Object AbstractSplitViewPy::sequence_item(ssize_t viewIndex)
|
||||||
{
|
{
|
||||||
testExistence();
|
testExistence();
|
||||||
if (viewIndex >= _view->getSize() or viewIndex < 0)
|
if (viewIndex >= _view->getSize() || viewIndex < 0)
|
||||||
throw Py::Exception("Index out of range");
|
throw Py::IndexError("Index out of range");
|
||||||
PyObject* viewer = _view->getViewer(viewIndex)->getPyObject();
|
PyObject* viewer = _view->getViewer(viewIndex)->getPyObject();
|
||||||
return Py::Object(viewer);
|
return Py::Object(viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbstractSplitViewPy::sequence_length()
|
int AbstractSplitViewPy::sequence_length()
|
||||||
{
|
{
|
||||||
|
testExistence();
|
||||||
return _view->getSize();
|
return _view->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,6 +666,7 @@ Py::Object AbstractSplitViewPy::close(const Py::Tuple& args)
|
||||||
|
|
||||||
return Py::None();
|
return Py::None();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|
||||||
TYPESYSTEM_SOURCE_ABSTRACT(Gui::SplitView3DInventor, Gui::AbstractSplitView);
|
TYPESYSTEM_SOURCE_ABSTRACT(Gui::SplitView3DInventor, Gui::AbstractSplitView);
|
||||||
|
@ -697,7 +706,6 @@ SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, Q
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSplitter* mainSplitter=0;
|
QSplitter* mainSplitter=0;
|
||||||
// minimal 2 views
|
// minimal 2 views
|
||||||
while (views < 2)
|
while (views < 2)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user