2008-03-13 15:55:28 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
"""
|
|
|
|
* pyPenNotes.py - pyPenNotes - initialize GUI
|
|
|
|
*
|
2008-04-02 17:37:18 +00:00
|
|
|
* (C) 2008 by Kristian Mueller <kristian-m@kristian-m.de>
|
2008-03-13 15:55:28 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
"""
|
|
|
|
import gtk
|
|
|
|
import gobject ## for multithreading
|
|
|
|
|
|
|
|
import notesList
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
from UserDrawingArea import UserDrawingArea
|
|
|
|
import SaveRestore
|
2008-03-13 15:55:28 +00:00
|
|
|
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
COLOR_LIST = ["#00000000ffff", "#ffff00000000", "#0000ffff0000", "#ffffffff0000", "#ffffffffffff", "#000000000000"]
|
2008-03-13 15:55:28 +00:00
|
|
|
DEFAULT_BG = 5 ## Black
|
|
|
|
DEFAULT_FG = 0 ## Blue
|
|
|
|
DEFAULT_SIZE = 4 ## Diameter 4 Pixel
|
|
|
|
DATA_FILE = "~/.penNotes.strokes_data"
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
QUALITY_LOSS = 5 ## Quality loss when removing unneeded points. Measured in pixels.
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
class pyPenNotes:
|
|
|
|
## init the class
|
|
|
|
def __init__(self):
|
|
|
|
self.state = "pre-init"
|
|
|
|
self.current_note_number = 0
|
|
|
|
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
|
|
self.window.set_default_size(480, 640)
|
|
|
|
self.window.set_title("pyPenNotes")
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.window.connect("destroy", self.end_program)
|
2008-03-13 15:55:28 +00:00
|
|
|
self.window.show()
|
|
|
|
self.more_options_visible = False
|
|
|
|
self.state = "init-done"
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.save_restore = SaveRestore.BasicFile(DATA_FILE)
|
|
|
|
self.save_restore.quality_loss = QUALITY_LOSS
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
def update_ui(self):
|
|
|
|
if self.state == "init-done":
|
|
|
|
self.create_window()
|
|
|
|
self.state = "running"
|
|
|
|
return False ## okay, we're done
|
|
|
|
else:
|
|
|
|
return True ## please come back later
|
|
|
|
|
|
|
|
## create content of the main window
|
|
|
|
## asynchronous - so we can have a faster start up
|
|
|
|
def create_window(self):
|
|
|
|
vbox = gtk.VBox()
|
2008-04-02 17:37:18 +00:00
|
|
|
main_toolbar = gtk.Toolbar()
|
|
|
|
main_toolbar.set_style(gtk.TOOLBAR_ICONS);
|
|
|
|
self.sub_toolbar = gtk.Toolbar()
|
|
|
|
self.sub_toolbar.set_style(gtk.TOOLBAR_ICONS);
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.area = UserDrawingArea()
|
|
|
|
self.area.line_width = DEFAULT_SIZE
|
2008-03-13 15:55:28 +00:00
|
|
|
self.table = gtk.Table(2,2)
|
|
|
|
self.hruler = gtk.HRuler()
|
|
|
|
self.vruler = gtk.VRuler()
|
2008-04-02 17:37:18 +00:00
|
|
|
self.hruler.set_range(0, 400, 0, 400) #todo
|
|
|
|
self.vruler.set_range(0, 300, 0, 300) #todo
|
2008-03-13 15:55:28 +00:00
|
|
|
self.table.attach(self.hruler, 1, 2, 0, 1, yoptions=0)
|
|
|
|
self.table.attach(self.vruler, 0, 1, 1, 2, xoptions=0)
|
2008-04-02 17:37:18 +00:00
|
|
|
self.table.attach(self.area, 1, 2, 1, 2)
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
size_evnt_box = gtk.EventBox()
|
|
|
|
self.size_number_entry = gtk.Label()
|
|
|
|
size_evnt_box.add(self.size_number_entry)
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.size_number_entry.set_text("%2.2dpx" % DEFAULT_SIZE)
|
2008-03-13 15:55:28 +00:00
|
|
|
self.size_number_entry.modify_fg(gtk.STATE_NORMAL, \
|
2008-04-02 17:37:18 +00:00
|
|
|
self.size_number_entry.get_colormap().alloc_color(\
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
COLOR_LIST[DEFAULT_FG]))
|
2008-03-13 15:55:28 +00:00
|
|
|
self.size_number_entry.set_width_chars(4) # max: "99 px"
|
|
|
|
size_evnt_box.set_events(gtk.gdk.BUTTON_PRESS_MASK)
|
|
|
|
size_evnt_box.connect("button_press_event", self.fg_color_select)
|
|
|
|
|
|
|
|
note_evnt_box = gtk.EventBox()
|
|
|
|
self.note_number_entry = gtk.Label()
|
|
|
|
note_evnt_box.add(self.note_number_entry)
|
|
|
|
self.note_number_entry.set_text("%4.4d" % (self.current_note_number+1))
|
|
|
|
self.note_number_entry.modify_fg(gtk.STATE_NORMAL, \
|
|
|
|
self.size_number_entry.get_colormap().\
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
alloc_color(COLOR_LIST[DEFAULT_BG]))
|
2008-03-13 15:55:28 +00:00
|
|
|
self.note_number_entry.set_width_chars(4)
|
|
|
|
note_evnt_box.set_events(gtk.gdk.BUTTON_PRESS_MASK)
|
|
|
|
note_evnt_box.connect("button_press_event", self.bg_color_select)
|
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
## fill in toolbar items ##############################################
|
|
|
|
#######################################################################
|
2008-04-02 17:37:18 +00:00
|
|
|
|
|
|
|
def create_toolbutton(stock, callback, expand = False):
|
|
|
|
btn = gtk.ToolButton(stock);
|
|
|
|
btn.connect("clicked", callback);
|
|
|
|
if(expand):
|
|
|
|
btn.set_expand(True)
|
|
|
|
return btn
|
|
|
|
|
2008-03-13 15:55:28 +00:00
|
|
|
## size <
|
2008-04-02 17:37:18 +00:00
|
|
|
main_toolbar.insert(create_toolbutton("gtk-go-back", self.prev_size), -1)
|
2008-03-13 15:55:28 +00:00
|
|
|
## size ??px
|
|
|
|
size_item = gtk.ToolItem()
|
|
|
|
size_item.add(size_evnt_box)
|
2008-04-02 17:37:18 +00:00
|
|
|
main_toolbar.insert(size_item, -1)
|
2008-03-13 15:55:28 +00:00
|
|
|
## size >
|
2008-04-02 17:37:18 +00:00
|
|
|
main_toolbar.insert(create_toolbutton("gtk-go-forward", self.next_size), -1)
|
|
|
|
main_toolbar.insert(gtk.SeparatorToolItem(), -1)
|
|
|
|
|
2008-03-13 15:55:28 +00:00
|
|
|
## cls
|
2008-04-02 17:37:18 +00:00
|
|
|
self.more_btn = gtk.ToggleToolButton("gtk-go-down");
|
|
|
|
self.more_btn.connect("toggled", self.more_options);
|
|
|
|
self.more_btn.set_expand(True);
|
|
|
|
main_toolbar.insert(self.more_btn, -1)
|
|
|
|
|
|
|
|
main_toolbar.insert(gtk.SeparatorToolItem(), -1)
|
|
|
|
|
2008-03-13 15:55:28 +00:00
|
|
|
## note <
|
2008-04-02 17:37:18 +00:00
|
|
|
main_toolbar.insert(create_toolbutton("gtk-go-back", self.prev_note), -1)
|
2008-03-13 15:55:28 +00:00
|
|
|
## note ????
|
|
|
|
note_item = gtk.ToolItem()
|
|
|
|
note_item.add(note_evnt_box)
|
2008-04-02 17:37:18 +00:00
|
|
|
main_toolbar.insert(note_item, -1)
|
2008-03-13 15:55:28 +00:00
|
|
|
## note >
|
2008-04-02 17:37:18 +00:00
|
|
|
main_toolbar.insert(create_toolbutton("gtk-go-forward", self.next_note), -1)
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
2008-04-02 17:37:18 +00:00
|
|
|
# Fill in the sub toolbar:
|
2008-03-13 15:55:28 +00:00
|
|
|
|
2008-04-02 17:37:18 +00:00
|
|
|
# Clear
|
|
|
|
self.sub_toolbar.insert(create_toolbutton("gtk-clear", self.clear_note, True), -1)
|
|
|
|
# Undo
|
|
|
|
self.sub_toolbar.insert(create_toolbutton("gtk-undo", self.undo, True), -1)
|
|
|
|
# Revert to saved
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.sub_toolbar.insert(create_toolbutton("gtk-revert-to-saved", self.revert_to_saved, True), -1)
|
2008-04-02 17:37:18 +00:00
|
|
|
# Save
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.sub_toolbar.insert(create_toolbutton("gtk-save", self.save, True),-1)
|
2008-04-02 17:37:18 +00:00
|
|
|
# Quit
|
|
|
|
self.sub_toolbar.insert(create_toolbutton("gtk-quit", self.end_program, True), -1)
|
2008-03-13 15:55:28 +00:00
|
|
|
|
2008-04-02 17:37:18 +00:00
|
|
|
#Experimental:
|
|
|
|
# self.sub_toolbar.insert(create_toolbutton(\
|
|
|
|
# "gtk-revert-to-saved-ltr", self.print_list_sub_number, True), -1)
|
|
|
|
# self.sub_toolbar.insert(create_toolbutton(\
|
|
|
|
# "gtk-revert-to-saved-ltr", self.print_list_number, True), -1)
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
2008-04-02 17:37:18 +00:00
|
|
|
vbox.pack_start(main_toolbar, False, False, 0)
|
|
|
|
vbox.pack_start(self.sub_toolbar, False, False, 0)
|
2008-03-13 15:55:28 +00:00
|
|
|
vbox.add(self.table);
|
|
|
|
self.window.add(vbox)
|
|
|
|
def motion_notify(ruler, event):
|
|
|
|
return ruler.emit("motion_notify_event", event)
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.area.add_events(gtk.gdk.POINTER_MOTION_MASK |
|
|
|
|
gtk.gdk.POINTER_MOTION_HINT_MASK )
|
2008-03-13 15:55:28 +00:00
|
|
|
self.area.connect_object("motion_notify_event", motion_notify,
|
|
|
|
self.hruler)
|
|
|
|
self.area.connect_object("motion_notify_event", motion_notify,
|
|
|
|
self.vruler)
|
|
|
|
|
|
|
|
def size_allocate_cb(wid, allocation):
|
|
|
|
x, y, w, h = allocation
|
|
|
|
l,u,p,m = self.hruler.get_range()
|
|
|
|
m = max(m, w)
|
|
|
|
self.hruler.set_range(l, l+w, p, m)
|
|
|
|
l,u,p,m = self.vruler.get_range()
|
|
|
|
m = max(m, h)
|
|
|
|
self.vruler.set_range(l, l+h, p, m)
|
2008-04-02 17:37:18 +00:00
|
|
|
self.area.connect('size-allocate', size_allocate_cb)
|
2008-03-13 15:55:28 +00:00
|
|
|
self.window.show_all()
|
2008-04-02 17:37:18 +00:00
|
|
|
self.sub_toolbar.hide() ## Hide to make space on screen
|
|
|
|
self.hruler.hide()
|
|
|
|
self.vruler.hide()
|
|
|
|
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.update_area()
|
2008-03-13 15:55:28 +00:00
|
|
|
|
2008-04-02 17:37:18 +00:00
|
|
|
|
|
|
|
|
2008-03-13 15:55:28 +00:00
|
|
|
###########################################################################
|
|
|
|
## callbacks ###########################################################
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
## debug correlation of notes list
|
|
|
|
def print_list_number(self, event):
|
|
|
|
for i in range(len(self.pen_notes)):
|
|
|
|
for j in range(len(self.pen_notes)):
|
|
|
|
print ""
|
2008-04-02 17:37:18 +00:00
|
|
|
notesList.pearson_correlation(self.pen_notes, i, j, "number", \
|
|
|
|
"sub_number")
|
2008-03-13 15:55:28 +00:00
|
|
|
#notesList.pearson_corr(self.pen_notes, 0, 1, "number")
|
|
|
|
|
|
|
|
## debug correlation of notes list
|
|
|
|
def print_list_sub_number(self, event):
|
2008-04-02 17:37:18 +00:00
|
|
|
notesList.pearson_correlation(self.pen_notes, 0, 1, "sub_number", \
|
|
|
|
"number")
|
2008-03-13 15:55:28 +00:00
|
|
|
#notesList.pearson_corr(self.pen_notes, 0, 1, "sub_number")
|
|
|
|
|
|
|
|
## change brush size--
|
|
|
|
def prev_size(self, event):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.area.line_width /= 2
|
|
|
|
if self.area.line_width <= 0:
|
|
|
|
self.area.line_width = 1
|
|
|
|
self.size_number_entry.set_text("%2.2d px" % self.area.line_width)
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
## change brush size++
|
|
|
|
def next_size(self, event):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.area.line_width *= 2
|
|
|
|
if self.area.line_width > 99:
|
|
|
|
self.area.line_width = 99
|
|
|
|
self.size_number_entry.set_text("%2.2d px" % self.area.line_width)
|
|
|
|
|
|
|
|
def load_changes_from_area(self):
|
|
|
|
"""Load changes made to the area, so that they can be saved."""
|
|
|
|
self.save_restore.set_note(self.current_note_number, \
|
|
|
|
SaveRestore.PenNote(self.area.get_bg_color(), self.area.get_strokes()))
|
|
|
|
|
|
|
|
def update_area(self):
|
|
|
|
"""Load notes with self.current_note_number and display them on the UserDrawingArea"""
|
|
|
|
note = self.save_restore.get_note(self.current_note_number)
|
|
|
|
self.area.set_bg_color(note.bg_color)
|
|
|
|
self.area.set_strokes(note.strokes)
|
|
|
|
|
|
|
|
self.note_number_entry.modify_fg(gtk.STATE_NORMAL, \
|
|
|
|
self.size_number_entry.get_colormap().\
|
|
|
|
alloc_color(self.area.get_bg_color()))
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
def prev_note(self, event):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
"""Select the previous note."""
|
|
|
|
self.load_changes_from_area()
|
2008-03-13 15:55:28 +00:00
|
|
|
if self.current_note_number > 0:
|
|
|
|
self.current_note_number -= 1
|
2008-04-02 17:37:18 +00:00
|
|
|
self.note_number_entry.set_text("%4.4d"%(self.current_note_number+1))
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.update_area()
|
|
|
|
|
2008-03-13 15:55:28 +00:00
|
|
|
def next_note(self, event):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
"""Select the next or a new note."""
|
|
|
|
self.load_changes_from_area()
|
2008-03-13 15:55:28 +00:00
|
|
|
self.current_note_number += 1
|
|
|
|
self.note_number_entry.set_text("%4.4d" % (self.current_note_number+1))
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.update_area()
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
def more_options(self, event):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
"""Show more options. (A second toolbar and the rulers.)"""
|
2008-03-13 15:55:28 +00:00
|
|
|
if self.more_options_visible:
|
2008-04-02 17:37:18 +00:00
|
|
|
self.sub_toolbar.hide()
|
|
|
|
self.hruler.hide()
|
|
|
|
self.vruler.hide()
|
2008-03-13 15:55:28 +00:00
|
|
|
self.more_options_visible = False
|
|
|
|
else:
|
2008-04-02 17:37:18 +00:00
|
|
|
self.sub_toolbar.show()
|
|
|
|
self.hruler.show()
|
|
|
|
self.vruler.show()
|
2008-03-13 15:55:28 +00:00
|
|
|
self.more_options_visible = True
|
|
|
|
|
|
|
|
def undo(self, event):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.area.undo()
|
|
|
|
|
|
|
|
def revert_to_saved(self, event):
|
|
|
|
self.save_restore.revert_changes()
|
|
|
|
self.update_area()
|
|
|
|
|
|
|
|
def save(self, event):
|
|
|
|
self.load_changes_from_area()
|
|
|
|
self.save_restore.save()
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
def end_program(self, event):
|
|
|
|
self.save(None)
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
gtk.main_quit()
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
## operation doing actual drawing to the screen ###########################
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
## increment foreground color - select new pen color
|
|
|
|
def fg_color_select(self, event, blub):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
index = COLOR_LIST.index(self.area.get_fg_color())
|
|
|
|
index += 1
|
|
|
|
if index >= len(COLOR_LIST):
|
|
|
|
index = 0 ## cycle around
|
|
|
|
self.area.set_fg_color(COLOR_LIST[index]);
|
2008-03-13 15:55:28 +00:00
|
|
|
self.size_number_entry.modify_fg(gtk.STATE_NORMAL, \
|
|
|
|
self.size_number_entry.get_colormap().\
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
alloc_color(COLOR_LIST[index]))
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
## increment background color
|
2008-03-13 15:55:28 +00:00
|
|
|
def bg_color_select(self, event, blub):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
index = COLOR_LIST.index(self.area.get_bg_color())
|
|
|
|
index += 1
|
|
|
|
if index >= len(COLOR_LIST):
|
|
|
|
index = 0 ## cycle around
|
|
|
|
self.area.set_bg_color(COLOR_LIST[index]);
|
2008-03-13 15:55:28 +00:00
|
|
|
## show color as fontcolor for note number
|
|
|
|
self.note_number_entry.modify_fg(gtk.STATE_NORMAL, \
|
|
|
|
self.size_number_entry.get_colormap().\
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
alloc_color(COLOR_LIST[index]))
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
## trow away the content of the note
|
|
|
|
def clear_note(self, event):
|
FEATURE: Compress Data
CLEANUP: Separating out much of the concern of the large pyPenNotes.py file into SaveRestore.py and UserDrawingArea.py
patch from haakeyar Thanks a lot!
--- Full Ticket Message ---
UserDrawingArea.py is a widget that the user can draw on and you can receive tha strokes that the user has drawn.
SaveRestore contains classes for saving and loading the data. It is split into two closes. A base class takes care of things in common for all file formats, while a subclass implements the actual file format. This way, we could easily implement other file formats, for example a text format where only parts of the file are loaded, to improve loading speed, or ability to save to an sqlite file.
In the base class, I have implemented a simple compression of the notes. Points closer than QUALITY_LOSS (currently set at 5) pixels are merged. This compressed a test note file with 77% and you can barely see the difference. I have attached the original file, the compressed file and a a file with two notes file, the compressed first and the original last (open this file in the original pyPenNotes and switch between the notes to see the difference).
There are also other ways to compress the notes even more (no need for more than two points in a straight line), but I have not implemented that (yet).
Maybe it would be better to move the compression to UserDrawingArea - it would have both good and bad sides.
pyPenNotes.py still has too much responsibility in my opinion - it both displays the window and coordinates SaveRestore and UserDrawingArea, but I haven't done anything about that (yet).
If you want to discuss any of the changes, feel free to contact me on IRC or mail me at my nick at gmail dot com if you want to discuss the changes.
git-svn-id: http://www.neo1973-germany.de/svn@73 46df4e5c-bc4e-4628-a0fc-830ba316316d
2008-04-24 18:21:45 +00:00
|
|
|
self.area.clear()
|
2008-03-13 15:55:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2008-04-02 17:37:18 +00:00
|
|
|
gobject.timeout_add(500, pyPenNotes.update_ui, py_pen_notes) # every 1/2 sec
|
2008-03-13 15:55:28 +00:00
|
|
|
try:
|
|
|
|
if gtk.gtk_version[0] == 2:
|
|
|
|
gtk.gdk.threads_init()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
gtk.gdk.threads_enter()
|
|
|
|
gtk.main()
|
|
|
|
gtk.gdk.threads_leave()
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
py_pen_notes = pyPenNotes()
|
|
|
|
main()
|