desktop.cpp revision 3d70339a90b4e30cd065dc91f7334fcba9cf7df6
1494N/A#define __SP_DESKTOP_C__
1637N/A#ifdef HAVE_CONFIG_H
1494N/A#include "inkscape-private.h"
1494N/A#include "desktop-events.h"
1494N/A#include "desktop-handles.h"
1494N/A#include "document.h"
1494N/A#include "message-stack.h"
1494N/A#include "selection.h"
1494N/A#include "select-context.h"
1494N/A#include "sp-namedview.h"
1494N/A#include "sp-item-group.h"
1494N/A#include "prefs-utils.h"
1494N/A#include "object-hierarchy.h"
1494N/A#include "display/canvas-arena.h"
1494N/A#include "display/nr-arena.h"
1494N/A#include "display/gnome-canvas-acetate.h"
1494N/A#include "display/sodipodi-ctrlrect.h"
1494N/A#include "display/sp-canvas-util.h"
1494N/A#include "display/canvas-temporary-item-list.h"
1494N/A#include "display/snap-indicator.h"
1494N/A#include "libnr/nr-matrix-div.h"
1494N/A#include "libnr/nr-rect-ops.h"
1494N/A#include "ui/dialog/dialog-manager.h"
1494N/A#include "message-context.h"
1494N/A#include "layer-manager.h"
1494N/A#include "event-log.h"
1494N/A#include "display/canvas-grid.h"
1494N/A#include "widgets/desktop-widget.h"
1494N/A#include "box3d-context.h"
1494N/A#include "display/sp-canvas.h"
1494N/Astatic gint _arena_handler (SPCanvasArena *arena, NRArenaItem *ai, GdkEvent *event, SPDesktop *desktop);
_dlg_mgr( 0 ),
namedview( 0 ),
canvas( 0 ),
selection( 0 ),
event_context( 0 ),
layer_manager( 0 ),
event_log( 0 ),
temporary_item_list( 0 ),
snapindicator( 0 ),
acetate( 0 ),
main( 0 ),
gridgroup( 0 ),
guides( 0 ),
drawing( 0 ),
sketch( 0 ),
controls( 0 ),
tempgroup ( 0 ),
table( 0 ),
page( 0 ),
page_border( 0 ),
current( 0 ),
zooms_past( 0 ),
zooms_future( 0 ),
dkey( 0 ),
number( 0 ),
window_state(0),
waiting_cursor( false ),
guides_active( false ),
gr_item( 0 ),
gr_point_type( 0 ),
gr_point_i( 0 ),
gr_fill_or_stroke( true ),
_layer_hierarchy( 0 ),
_widget( 0 ),
_inkscape( 0 ),
_guides_message_context( 0 ),
_active( false ),
_w2d(),
_d2w(),
grids_visible( false )
_guides_message_context = new Inkscape::MessageContext(const_cast<Inkscape::MessageStack*>(messageStack()));
SP_CANVAS_ARENA (drawing)->arena->delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0); // default is 1 px
_modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
dkey,
if (ai) {
activate_guides (true);
if (snapindicator) {
delete snapindicator;
if (temporary_item_list) {
delete temporary_item_list;
g_signal_handlers_disconnect_by_func(G_OBJECT (acetate), (gpointer) G_CALLBACK(sp_desktop_root_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT (main), (gpointer) G_CALLBACK(sp_desktop_root_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT (drawing), (gpointer) G_CALLBACK(_arena_handler), this);
while (event_context) {
if (_layer_hierarchy) {
delete _layer_hierarchy;
if (layer_manager) {
delete layer_manager;
if (_inkscape) {
if (drawing) {
delete _guides_message_context;
* it is perfectly safe to ignore the returned pointer: the object is deleted by itself, so don't delete it elsewhere!
* The return value should only be used as argument for SPDesktop::remove_temporary_canvasitem, because the object might be deleted already.
/** It is perfectly safe to call this function while the object has already been deleted due to a timeout.
// check for non-null temporary_item_list, because during destruction of desktop, some destructor might try to access this list!
g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) );
return object;
if (bbox) {
if (new_active) {
while (event_context) {
SPItem *
SPItem *
SPItem *
if (log) {
double newscale;
newscale = CLAMP(newscale, SP_DESKTOP_ZOOM_MIN, SP_DESKTOP_ZOOM_MAX); // unit: 'screen pixels' per 'document pixels'
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
if (fabs(expansion(_d2w) - zoom) < 0.0001*zoom && (fabs(SP_DESKTOP_ZOOM_MAX - zoom) < 0.01 || fabs(SP_DESKTOP_ZOOM_MIN - zoom) < 0.000001))
sp_canvas_scroll_to(canvas, viewbox.min()[NR::X] - dx, viewbox.min()[NR::Y] - dy, FALSE, is_scrolling);
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
gdouble autoscrolldistance = (gdouble) prefs_get_int_attribute_limited ("options.autoscrolldistance", "value", 0, -1000, 10000);
if (autoscrollspeed == 0)
autoscrollspeed = prefs_get_double_attribute_limited ("options.autoscrollspeed", "value", 1, 0, 10);
if (autoscrollspeed != 0)
if(shutdown())
* Called when the window changes its maximize/fullscreen/iconify/pinned state.
layoutWidget();
inkscape_subselection_changed (this);
waiting_cursor = true;
// Stupidly broken GDK cannot just set the new cursor right now - it needs some main loop iterations for that
// Since setting waiting_cursor is usually immediately followed by some Real Work, we must run the iterations here
// CAUTION: iterations may redraw, and redraw may be interrupted, so you cannot assume that anything is the same
if (waiting_cursor)
if(gridgroup) {
Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR);
showGrids(true);
if (show) {
if (main) {
if (_layer_hierarchy) {
delete _layer_hierarchy;
if (drawing) {
_modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
dkey,
if (ai) {
activate_guides (true);
if (_widget) {
if (item) {
static gint
if (ai) {
SPObject * newLayer = SP_OBJECT_DOCUMENT(desktop->namedview)->getObjectById(desktop->_reconstruction_old_layer_id);
SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "onlight", 0xff);
SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs_get_int_attribute("options.wireframecolors", "ondark", 0xffffffff);
px));
px));
px));
return _w2d;
return p * _w2d;
return p * _d2w;
return _doc2dt;
return p * _doc2dt;
return p / _doc2dt;