presentation
andreasb123 15 years ago
parent 6ad2ae3dd4
commit b66d50258d
  1. 35
      src/plugin/python/bindings/PyXournal.cpp
  2. 14
      src/plugin/python/documentation/Xournal.java
  3. 32
      testing/tools/ToolEraser/ToolEraser.py
  4. BIN
      testing/tools/ToolEraser/resultDelete.xoj
  5. BIN
      testing/tools/ToolEraser/resultStandard.xoj
  6. BIN
      testing/tools/ToolEraser/resultWhiteout.xoj

@ -442,6 +442,31 @@ PyXournal_setCurrentPageBackground(PyXournal * self, PyObject * args) {
Py_RETURN_NONE;
}
static PyObject *
PyXournal_getEraserType(PyXournal * self) {
EraserType type = self->control->getToolHandler()->getEraserType();
return PyInt_FromLong(type);
}
static PyObject *
PyXournal_setEraserType(PyXournal * self, PyObject * args) {
int eraserType = -1;
if (!PyArg_ParseTuple(args, "i", &eraserType)) {
PyErr_SetString(PyExc_AttributeError, "int");
return NULL;
}
if (eraserType < ERASER_TYPE_DEFAULT || eraserType > ERASER_TYPE_DELETE_STROKE) {
PyErr_SetString(PyExc_AttributeError, "Erasertype out of range, please use the constants BACKGROUND_TYPE_*");
return NULL;
}
self->control->getToolHandler()->setEraserType((EraserType)eraserType);
Py_RETURN_NONE;
}
static PyMethodDef PyXournal_methods[] = {
{ "setSelectedTool", (PyCFunction) PyXournal_setSelectedTool, METH_VARARGS, "Selects a tool (see constatns TOOL_*" },
{ "getSelectedTool", (PyCFunction) PyXournal_getSelectedTool, METH_NOARGS, "Return the selected tool" },
@ -465,8 +490,8 @@ static PyMethodDef PyXournal_methods[] = {
{ "getToolSize", (PyCFunction) PyXournal_getToolSize, METH_NOARGS, "Return the selected tool size" },
{ "getCurrentPageBackground", (PyCFunction) PyXournal_getCurrentPageBackground, METH_NOARGS, "Return the background type of the current page (see BACKGROUND_TYPE_*)" },
{ "setCurrentPageBackground", (PyCFunction) PyXournal_setCurrentPageBackground, METH_VARARGS, "Set the background type of the current page (see BACKGROUND_TYPE_*)\nDon't use BACKGROUND_TYPE_PDF or BACKGROUND_TYPE_PDF" },
// { "xxxxxxxxxxxxx", (PyCFunction) xxxxxxxxxxxxxxxxx, METH_VARARGS, "Xxxxxxxxxxxxxxxx" },
// { "xxxxxxxxxxxxx", (PyCFunction) xxxxxxxxxxxxxxxxx, METH_VARARGS, "Xxxxxxxxxxxxxxxx" },
{ "setEraserType", (PyCFunction) PyXournal_setEraserType, METH_VARARGS, "Set the eraser type (ERASER_TYPE_*)" },
{ "getEraserType", (PyCFunction) PyXournal_getEraserType, METH_VARARGS, "Returns the eraser type (ERASER_TYPE_*)" },
// { "xxxxxxxxxxxxx", (PyCFunction) xxxxxxxxxxxxxxxxx, METH_VARARGS, "Xxxxxxxxxxxxxxxx" },
// { "xxxxxxxxxxxxx", (PyCFunction) xxxxxxxxxxxxxxxxx, METH_VARARGS, "Xxxxxxxxxxxxxxxx" },
// { "xxxxxxxxxxxxx", (PyCFunction) xxxxxxxxxxxxxxxxx, METH_VARARGS, "Xxxxxxxxxxxxxxxx" },
@ -545,8 +570,6 @@ void initxournal() {
ADD_CONST(TOOL_SIZE_THICK);
ADD_CONST(TOOL_SIZE_VERY_THICK);
ADD_CONST(BACKGROUND_TYPE_NONE);
ADD_CONST(BACKGROUND_TYPE_PDF);
ADD_CONST(BACKGROUND_TYPE_IMAGE);
@ -554,6 +577,10 @@ void initxournal() {
ADD_CONST(BACKGROUND_TYPE_RULED);
ADD_CONST(BACKGROUND_TYPE_GRAPH);
ADD_CONST(ERASER_TYPE_DEFAULT);
ADD_CONST(ERASER_TYPE_WHITEOUT);
ADD_CONST(ERASER_TYPE_DELETE_STROKE);
m = Py_InitModule3("xournal", module_methods, "Xournal API modul");
if (m == NULL) {

@ -24,6 +24,10 @@ public interface Xournal {
int BACKGROUND_TYPE_RULED = 5;
int BACKGROUND_TYPE_GRAPH = 6;
int ERASER_TYPE_DEFAULT = 1;
int ERASER_TYPE_WHITEOUT = 2;
int ERASER_TYPE_DELETE_STROKE = 3;
/**
* Sets the current tool
* @param tool A constant defined above
@ -78,6 +82,16 @@ public interface Xournal {
*/
boolean isShapeRecognizerEnabled();
/**
* Set the eraser type (ERASER_TYPE_*)
*/
void setEraserType(int eraserType);
/**
* Returns the eraser type (ERASER_TYPE_*)
*/
int getEraserType();
/**
* Return the background type of the current page (see BACKGROUND_TYPE_*)
*/

@ -21,16 +21,38 @@ class ToolEraser(ToolTest):
self.testDeleteStroke()
def testWhiteout(self):
path = os.path.realpath(__file__ + '/../source.xoj')
self.xoj.openFile(path)
self.xoj.setEraserType(self.xoj.ERASER_TYPE_WHITEOUT)
self.doTestInput()
path = os.path.realpath(__file__ + '/../resultWhiteout.xoj')
self.checkContents(path)
def testStandard(self):
# test with normal stroke, with pressure, with ruler
pass
self.xoj.newFile(True)
path = os.path.realpath(__file__ + '/../source.xoj')
self.xoj.openFile(path)
self.xoj.setEraserType(self.xoj.ERASER_TYPE_DEFAULT)
points = [[100, 40]]
points.append([150, 300]);
self.mouseInput(points, 1);
path = os.path.realpath(__file__ + '/../resultStandard.xoj')
self.checkContents(path)
def testDeleteStroke(self):
pass
self.xoj.newFile(True)
path = os.path.realpath(__file__ + '/../source.xoj')
self.xoj.openFile(path)
self.xoj.setEraserType(self.xoj.ERASER_TYPE_DELETE_STROKE)
points = [[100, 40]]
points.append([150, 300]);
self.mouseInput(points, 1);
path = os.path.realpath(__file__ + '/../resultDelete.xoj')
self.checkContents(path)

Loading…
Cancel
Save