presentation
andreasb123 15 years ago
parent 7287be7143
commit 8388d90d5e
  1. 1
      src/Makefile.am
  2. 23
      src/Makefile.in
  3. 5
      src/control/ZoomControl.cpp
  4. 5
      src/control/tools/EditSelection.cpp
  5. 18
      src/control/tools/EditSelectionContents.cpp
  6. 4
      src/control/tools/Selection.cpp
  7. 1
      src/plugin/python/bindings/PyUndoRedoHandler.cpp
  8. 16
      src/plugin/python/bindings/PyUndoRedoHandler.h
  9. 23
      testing/Test.py
  10. 4
      testing/XournalTest.py
  11. 3
      testing/undo/ColorUndoAction/Test.py
  12. 18
      testing/undo/UndoRedoTest.py

@ -172,6 +172,7 @@ xournalpp_SOURCES = \
if ENABLE_PYTHON
xournalpp_SOURCES += \
plugin/python/bindings/PyUndoRedoHandler.cpp \
plugin/python/bindings/PyXournal.cpp \
plugin/python/PythonRunner.cpp
endif

@ -37,6 +37,7 @@ host_triplet = @host@
target_triplet = @target@
bin_PROGRAMS = xournalpp$(EXEEXT)
@ENABLE_PYTHON_TRUE@am__append_1 = \
@ENABLE_PYTHON_TRUE@ plugin/python/bindings/PyUndoRedoHandler.cpp \
@ENABLE_PYTHON_TRUE@ plugin/python/bindings/PyXournal.cpp \
@ENABLE_PYTHON_TRUE@ plugin/python/PythonRunner.cpp
@ -145,9 +146,12 @@ am__xournalpp_SOURCES_DIST = control/jobs/AutosaveJob.cpp \
util/Range.cpp util/Rectangle.cpp util/String.cpp \
util/Util.cpp util/XInputUtils.cpp util/XournalType.cpp \
view/DocumentView.cpp view/PdfView.cpp view/TextView.cpp \
Xournalpp.cpp plugin/python/bindings/PyXournal.cpp \
Xournalpp.cpp plugin/python/bindings/PyUndoRedoHandler.cpp \
plugin/python/bindings/PyXournal.cpp \
plugin/python/PythonRunner.cpp
@ENABLE_PYTHON_TRUE@am__objects_1 = xournalpp-PyXournal.$(OBJEXT) \
@ENABLE_PYTHON_TRUE@am__objects_1 = \
@ENABLE_PYTHON_TRUE@ xournalpp-PyUndoRedoHandler.$(OBJEXT) \
@ENABLE_PYTHON_TRUE@ xournalpp-PyXournal.$(OBJEXT) \
@ENABLE_PYTHON_TRUE@ xournalpp-PythonRunner.$(OBJEXT)
am_xournalpp_OBJECTS = xournalpp-AutosaveJob.$(OBJEXT) \
xournalpp-BlockingJob.$(OBJEXT) xournalpp-ExportJob.$(OBJEXT) \
@ -713,6 +717,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xournalpp-Point.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xournalpp-PreviewJob.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xournalpp-PrintHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xournalpp-PyUndoRedoHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xournalpp-PyXournal.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xournalpp-PythonRunner.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xournalpp-Range.Po@am__quote@
@ -3087,6 +3092,20 @@ xournalpp-Xournalpp.obj: Xournalpp.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xournalpp_CXXFLAGS) $(CXXFLAGS) -c -o xournalpp-Xournalpp.obj `if test -f 'Xournalpp.cpp'; then $(CYGPATH_W) 'Xournalpp.cpp'; else $(CYGPATH_W) '$(srcdir)/Xournalpp.cpp'; fi`
xournalpp-PyUndoRedoHandler.o: plugin/python/bindings/PyUndoRedoHandler.cpp
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xournalpp_CXXFLAGS) $(CXXFLAGS) -MT xournalpp-PyUndoRedoHandler.o -MD -MP -MF $(DEPDIR)/xournalpp-PyUndoRedoHandler.Tpo -c -o xournalpp-PyUndoRedoHandler.o `test -f 'plugin/python/bindings/PyUndoRedoHandler.cpp' || echo '$(srcdir)/'`plugin/python/bindings/PyUndoRedoHandler.cpp
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/xournalpp-PyUndoRedoHandler.Tpo $(DEPDIR)/xournalpp-PyUndoRedoHandler.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='plugin/python/bindings/PyUndoRedoHandler.cpp' object='xournalpp-PyUndoRedoHandler.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xournalpp_CXXFLAGS) $(CXXFLAGS) -c -o xournalpp-PyUndoRedoHandler.o `test -f 'plugin/python/bindings/PyUndoRedoHandler.cpp' || echo '$(srcdir)/'`plugin/python/bindings/PyUndoRedoHandler.cpp
xournalpp-PyUndoRedoHandler.obj: plugin/python/bindings/PyUndoRedoHandler.cpp
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xournalpp_CXXFLAGS) $(CXXFLAGS) -MT xournalpp-PyUndoRedoHandler.obj -MD -MP -MF $(DEPDIR)/xournalpp-PyUndoRedoHandler.Tpo -c -o xournalpp-PyUndoRedoHandler.obj `if test -f 'plugin/python/bindings/PyUndoRedoHandler.cpp'; then $(CYGPATH_W) 'plugin/python/bindings/PyUndoRedoHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/plugin/python/bindings/PyUndoRedoHandler.cpp'; fi`
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/xournalpp-PyUndoRedoHandler.Tpo $(DEPDIR)/xournalpp-PyUndoRedoHandler.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='plugin/python/bindings/PyUndoRedoHandler.cpp' object='xournalpp-PyUndoRedoHandler.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xournalpp_CXXFLAGS) $(CXXFLAGS) -c -o xournalpp-PyUndoRedoHandler.obj `if test -f 'plugin/python/bindings/PyUndoRedoHandler.cpp'; then $(CYGPATH_W) 'plugin/python/bindings/PyUndoRedoHandler.cpp'; else $(CYGPATH_W) '$(srcdir)/plugin/python/bindings/PyUndoRedoHandler.cpp'; fi`
xournalpp-PyXournal.o: plugin/python/bindings/PyXournal.cpp
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xournalpp_CXXFLAGS) $(CXXFLAGS) -MT xournalpp-PyXournal.o -MD -MP -MF $(DEPDIR)/xournalpp-PyXournal.Tpo -c -o xournalpp-PyXournal.o `test -f 'plugin/python/bindings/PyXournal.cpp' || echo '$(srcdir)/'`plugin/python/bindings/PyXournal.cpp
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/xournalpp-PyXournal.Tpo $(DEPDIR)/xournalpp-PyXournal.Po

@ -2,6 +2,11 @@
const double zoomStep = 0.2;
/**
* TODO: zoom is not fluently if you have much data
* Why?
*/
ZoomControl::ZoomControl() {
XOJ_INIT_TYPE(ZoomControl);

@ -89,9 +89,6 @@ EditSelection::~EditSelection() {
delete this->contents;
this->contents = NULL;
this->view->rerenderPage();
this->view->getXournal()->repaintSelection(true);
this->view = NULL;
this->undo = NULL;
@ -114,7 +111,7 @@ void EditSelection::finalizeSelection() {
this->contents->finalizeSelection(this->x, this->y, this->width, this->height, this->aspectRatio, layer, page, this->view, this->undo);
this->view->rerenderPage();
this->view->rerenderRect(this->x, this->y, this->width, this->height);
// This is needed if the selection not was 100% on a page
this->view->getXournal()->repaintSelection();

@ -30,8 +30,8 @@ EditSelectionContents::EditSelectionContents(double x, double y, double width, d
this->originalWidth = width;
this->originalHeight = height;
this->relativeX = ceil(x);
this->relativeY = ceil(y);
this->relativeX = 0;
this->relativeY = 0;
this->originalX = x;
this->originalY = y;
@ -327,12 +327,18 @@ void EditSelectionContents::paint(cairo_t * cr, double x, double y, double width
double fx = width / this->originalWidth;
double fy = height / this->originalHeight;
int dx = (int) (x * zoom);
int dy = (int) (y * zoom);
if (this->crBuffer == NULL) {
this->crBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width * zoom, height * zoom);
cairo_t * cr2 = cairo_create(this->crBuffer);
cairo_scale(cr2, zoom * fx, zoom * fy);
this->relativeX = dx;
this->relativeY = dy;
cairo_translate(cr2, -this->relativeX, -this->relativeY);
cairo_scale(cr2, zoom * fx, zoom * fy);
DocumentView view;
view.drawSelection(cr2, this);
@ -358,9 +364,11 @@ void EditSelectionContents::paint(cairo_t * cr, double x, double y, double width
cairo_scale(cr, sx, sy);
}
cairo_set_source_surface(cr, this->crBuffer, (int) (x * zoom / sx), (int) (y * zoom / sy));
dx = (int) (x * zoom / sx);
dy = (int) (y * zoom / sy);
cairo_set_source_surface(cr, this->crBuffer, dx, dy);
cairo_paint(cr);
cairo_restore(cr);
}

@ -87,8 +87,6 @@ bool RectSelection::finalize(PageRef page) {
}
}
view->repaintArea(x1, y1, x2, y2);
return this->selectedElements != NULL;
}
@ -359,8 +357,6 @@ bool RegionSelect::finalize(PageRef page) {
}
}
view->repaintArea(this->x1Box, this->y1Box, this->x2Box, this->y2Box);
return this->selectedElements != NULL;
}

@ -0,0 +1 @@
#include "PyUndoRedoHandler.h"

@ -0,0 +1,16 @@
/*
* Xournal++
*
* Python bindings for Undo- / Redohandler
*
* @author Xournal Team
* http://xournal.sf.net
*
* @license GPL
*/
#ifndef __PYUNDOREDOHANDLER_H_
#define __PYUNDOREDOHANDLER_H_
#endif /* PYUNDOREDOHANDLER_H_ */

@ -7,9 +7,13 @@ def xournalTest(args = ''):
xoj = xournal.Xournal()
print '=== Xournal Testsuit ===\n'
xournalRunTestInSubfolder(xoj, 'tools');
xournalRunTestInSubfolder(xoj, 'undo');
print '\n=== End Xournal Testsuit ===\n'
def xournalRunTestInSubfolder(xoj, subfolder):
path = os.path.realpath(__file__)
@ -24,10 +28,21 @@ def xournalRunTestInSubfolder(xoj, subfolder):
if os.path.isdir(dirfile) and not name.startswith('.') and os.path.exists(os.path.join(dirfile, 'Test.py')):
print 'Run test in %s' % dirfile
print 'Debug: import %s from %s' % (name, subfolder + '.' + name + '.Test')
__import__(subfolder + '.' + name + '.Test', fromlist = name)
cls = globals()[name]
inst = cls()
inst.
try:
sFrom = subfolder + '.' + name + '.Test'
moduleObject = __import__(sFrom, globals(), locals(), [name], -1)
classObject = getattr(moduleObject, name)
obj = classObject()
obj.test(xoj)
except (AssertionError) as e:
print type(e) # the exception instance
print e.args # arguments stored in .args
print e
except (Exception) as e:
print "Test %s Unexpected error:" % name, type(e)
print e.args # arguments stored in .args
print e

@ -7,7 +7,9 @@
#
# @license GPL
class ColorUndoAction(UndoRedoTest):
class XournalTest:
def __init__(self, xoj):
self.xoj = xoj
def test(self, xoj):
self.tearUp(xoj)

@ -12,5 +12,6 @@ from undo.UndoRedoTest import UndoRedoTest
class ColorUndoAction(UndoRedoTest):
def __init__(self):
UndoRedoTest.__init__(self)
print 'ColorUndoAction'

@ -7,11 +7,19 @@
#
# @license GPL
from XournalTest import XournalTest
class UndoRedoTest:
def __init__(self):
print 'UndoRedoTest\n'
class UndoRedoTest(XournalTest):
def __init__(self, xoj):
XournalTest.__init__(self, xoj)
# TODO debug
print xoj.getUndoRedoHandler()
def tearUp(self, xoj):
print 'UndoRedoTest.tearUp'
def tearDown(self, xoj):
print 'UndoRedoTest.tearDown'
def runTest(self):
print 'run test called!\n'

Loading…
Cancel
Save