sp-namedview.cpp revision 4aabf2a995bdba7a42110f4292cb0e194722e429
#define __SP_NAMEDVIEW_C__
/*
* <sodipodi:namedview> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 1999-2005 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "config.h"
#include "display/canvas-grid.h"
#include "display/canvas-axonomgrid.h"
#include "svg/svg-color.h"
#include "attributes.h"
#include "document.h"
#include "desktop-events.h"
#include "desktop-handles.h"
#include "event-log.h"
#include "sp-guide.h"
#include "sp-item-group.h"
#include "sp-namedview.h"
#include "prefs-utils.h"
#include "desktop.h"
#include "conn-avoid-ref.h" // for defaultConnSpacing.
#include "isnan.h" //temp fix for isnan(). include last
#define DEFAULTTOLERANCE 0.4
#define DEFAULTGRIDCOLOR 0x3f3fff25
#define DEFAULTGRIDEMPCOLOR 0x3f3fff60
#define DEFAULTGRIDEMPSPACING 5
#define DEFAULTGUIDECOLOR 0x0000ff7f
#define DEFAULTGUIDEHICOLOR 0xff00007f
#define DEFAULTBORDERCOLOR 0x000000ff
#define DEFAULTPAGECOLOR 0xffffff00
static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
static SPObjectGroupClass * parent_class;
{
static GType namedview_type = 0;
if (!namedview_type) {
sizeof(SPNamedViewClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof(SPNamedView),
16, /* n_preallocs */
NULL, /* value_table */
};
namedview_type = g_type_register_static(SP_TYPE_OBJECTGROUP, "SPNamedView", &namedview_info, (GTypeFlags)0);
}
return namedview_type;
}
{
}
{
nv->default_layer_id = 0;
}
{
}
/* Construct guideline list */
if (SP_IS_GUIDE(o)) {
}
}
}
{
}
}
}
}
{
switch (key) {
case SP_ATTR_VIEWONLY:
break;
case SP_ATTR_SHOWGRID:
/* Disable grid snaps if the grid is turned off */
break;
case SP_ATTR_GRIDTYPE:
break;
case SP_ATTR_SHOWGUIDES:
if (!value) { // show guides if not specified, for backwards compatibility
} else {
}
break;
case SP_ATTR_GRIDTOLERANCE:
if (value) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->gridtolerance, &nv->gridtoleranceunit);
}
break;
case SP_ATTR_GUIDETOLERANCE:
if (value) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->guidetolerance, &nv->guidetoleranceunit);
}
break;
case SP_ATTR_OBJECTTOLERANCE:
if (value) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->objecttolerance, &nv->objecttoleranceunit);
}
break;
case SP_ATTR_ABS_TOLERANCE:
if (!value)
nv->has_abs_tolerance = true;
else
break;
case SP_ATTR_GRIDORIGINX:
case SP_ATTR_GRIDORIGINY:
{
unsigned const d = (key == SP_ATTR_GRIDORIGINY);
if (value) {
}
break;
}
case SP_ATTR_GRIDSPACINGX:
case SP_ATTR_GRIDSPACINGY:
{
unsigned const d = (key == SP_ATTR_GRIDSPACINGY);
if (value) {
}
break;
}
case SP_ATTR_GRIDANGLEX:
case SP_ATTR_GRIDANGLEZ:
{
if (value) {
}
break;
}
case SP_ATTR_GRIDCOLOR:
if (value) {
}
break;
case SP_ATTR_GRIDEMPCOLOR:
if (value) {
}
break;
case SP_ATTR_GRIDOPACITY:
break;
case SP_ATTR_GRIDEMPOPACITY:
break;
case SP_ATTR_GRIDEMPSPACING:
break;
case SP_ATTR_GUIDECOLOR:
if (value) {
}
}
break;
case SP_ATTR_GUIDEOPACITY:
}
break;
case SP_ATTR_GUIDEHICOLOR:
if (value) {
}
}
break;
case SP_ATTR_GUIDEHIOPACITY:
}
break;
case SP_ATTR_SHOWBORDER:
break;
case SP_ATTR_BORDERLAYER:
break;
case SP_ATTR_BORDERCOLOR:
if (value) {
}
break;
case SP_ATTR_BORDEROPACITY:
break;
case SP_ATTR_PAGECOLOR:
if (value) {
}
break;
break;
break;
case SP_ATTR_SHOWPAGESHADOW:
break;
case SP_ATTR_INKSCAPE_ZOOM:
break;
case SP_ATTR_INKSCAPE_CX:
break;
case SP_ATTR_INKSCAPE_CY:
break;
break;
break;
break;
break;
nv->snap_manager.grid.setSnapTo(Inkscape::Snapper::BBOX_POINT, value ? sp_str_to_bool(value) : TRUE);
nv->snap_manager.axonomgrid.setSnapTo(Inkscape::Snapper::BBOX_POINT, value ? sp_str_to_bool(value) : TRUE);
break;
nv->snap_manager.grid.setSnapTo(Inkscape::Snapper::SNAP_POINT, value ? sp_str_to_bool(value) : FALSE);
nv->snap_manager.axonomgrid.setSnapTo(Inkscape::Snapper::SNAP_POINT, value ? sp_str_to_bool(value) : FALSE);
break;
nv->snap_manager.guide.setSnapTo(Inkscape::Snapper::BBOX_POINT, value ? sp_str_to_bool(value) : TRUE);
break;
nv->snap_manager.guide.setSnapTo(Inkscape::Snapper::SNAP_POINT, value ? sp_str_to_bool(value) : FALSE);
break;
nv->snap_manager.object.setSnapTo(Inkscape::Snapper::BBOX_POINT, (value) ? sp_str_to_bool(value) : FALSE);
break;
nv->snap_manager.object.setSnapTo(Inkscape::Snapper::SNAP_POINT, (value) ? sp_str_to_bool(value) : FALSE);
break;
break;
break;
break;
break;
case SP_ATTR_INKSCAPE_DOCUMENT_UNITS: {
/* The default unit if the document doesn't override this: e.g. for files saved as
* `plain SVG', or non-inkscape files, or files created by an inkscape 0.40 &
* earlier.
*
* Here we choose `px': useful for screen-destined SVGs, and fewer bug reports
* about "not the same numbers as what's in the SVG file" (at least for documents
* without a viewBox attribute on the root <svg> element). Similarly, it's also
* the most reliable unit (i.e. least likely to be wrong in different viewing
* conditions) for viewBox-less SVG files given that it's the unit that inkscape
* uses for all coordinates.
*
* For documents that do have a viewBox attribute on the root <svg> element, it
* might be better if we used either viewBox coordinates or if we used the unit of
* say the width attribute of the root <svg> element. However, these pose problems
* in that they aren't in general absolute units as currently required by
* doc_units.
*/
if (value) {
/* fixme: Document errors should be reported in the status bar or
* the like (e.g. as per
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log
* should be only for programmer errors. */
} else {
g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'",
value);
/* fixme: Don't use g_log (see above). */
}
}
break;
}
default:
}
break;
}
}
static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
{
}
if (SP_IS_GUIDE(no)) {
TRUE);
if (nv->showguides) {
}
} else {
}
}
}
}
}
}
{
break;
}
}
}
}
static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
{
if ( ( flags & SP_OBJECT_WRITE_EXT ) &&
{
if (repr) {
} else {
}
}
return repr;
}
{
if (desktop->guides_active) {
}
if (showguides) {
}
} else {
}
}
}
// since we're keeping a copy, we need to bump up the ref count
// since we're keeping a copy, we need to bump up the ref count
sp_namedview_setup_grid(this);
}
#define MIN_ONSCREEN_DISTANCE 50
/*
* Restores window geometry from the document settings
*/
{
// restore window size and position
if (save_geometry) {
if (w>0 && h>0 && x>0 && y>0) {
x = MIN(gdk_screen_width() - w, x);
y = MIN(gdk_screen_height() - h, y);
}
if (w>0 && h>0)
desktop->setWindowSize(w, h);
if (x>0 && y>0)
}
// restore zoom and view
}
// cancel any history of zooms up to this point
if (desktop->zooms_past) {
}
}
{
if ( nv->default_layer_id != 0 ) {
}
// don't use that object if it's not at least group
}
// if that didn't work out, look for the topmost layer
if (!layer) {
}
}
}
if (layer) {
}
// FIXME: find a better place to do this
}
{
// saving window geometry is not undoable
if (save_geometry) {
gint w, h, x, y;
desktop->getWindowGeometry(x, y, w, h);
}
// restore undoability
}
{
}
GSList *l;
if (! l->data) {
continue;
}
}
}
}
{
}
}
{
if (nv->showguides) {
}
} else {
}
}
}
}
{
unsigned int v;
if (!set) { // hide guides if not specified, for backwards compatibility
v = FALSE;
} else {
v = !v;
}
sp_document_set_undo_sensitive(doc, false);
}
{
unsigned int v;
v = !v;
sp_document_set_undo_sensitive(doc, false);
}
{
sp_document_set_undo_sensitive(doc, false);
}
{
}
}
{
} else {
}
NULL);
if (!btype){
// CXYGRID
NULL);
} else {
// CAXONOMGRID
NULL);
}
}
{
}
{
return ++viewcount;
}
{
return views;
}
/* This should be moved somewhere */
{
if (str) {
return TRUE;
}
}
return FALSE;
}
/* fixme: Collect all these length parsing methods and think common sane API */
{
if (!str) {
return FALSE;
}
gchar *u;
if (!u) {
return FALSE;
}
while (isspace(*u)) {
u += 1;
}
if (!*u) {
/* No unit specified - keep default */
*val = v;
return TRUE;
}
if (base & SP_UNIT_DEVICE) {
*val = v;
return TRUE;
}
}
if (base & SP_UNIT_ABSOLUTE) {
} else {
return FALSE;
}
*val = v;
return TRUE;
}
return FALSE;
}
{
if (!str) {
return FALSE;
}
gchar *u;
if (!u) {
return FALSE;
}
return TRUE;
}
{
SPObject *nv = sp_item_group_get_child_by_name((SPGroup *) document->root, NULL, "sodipodi:namedview");
return (SPNamedView *) nv;
}
}
return (SPNamedView *) nv;
}
/**
* Returns namedview's default metric.
*/
{
if (doc_units) {
return sp_unit_get_metric(doc_units);
} else {
return SP_PT;
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :