box3d-side.cpp revision 9e470e2bfedc3d5550406c9996463013721355a3
#define __BOX3D_SIDE_C__
/*
* 3D box face implementation
*
* Authors:
* Maximilian Albert <Anhalter42@gmx.de>
*
* Copyright (C) 2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "box3d-side.h"
#include "document.h"
#include "xml/document.h"
#include "attributes.h"
#include "inkscape.h"
#include "persp3d.h"
#include "box3d-context.h"
#include "prefs-utils.h"
#include "desktop-style.h"
#include "box3d.h"
static Inkscape::XML::Node *box3d_side_write (SPObject *object, Inkscape::XML::Node *repr, guint flags);
//static gchar * box3d_side_description (SPItem * item);
//static void box3d_side_snappoints(SPItem const *item, SnapPointsIter p);
//static void box3d_side_set_shape (SPShape *shape);
//static void box3d_side_update_patheffect (SPShape *shape, bool write);
// static gint box3d_side_descr_to_id (gchar const *descr);
static SPShapeClass *parent_class;
box3d_side_get_type (void)
{
if (!type) {
sizeof (Box3DSideClass),
sizeof (Box3DSide),
16,
NULL, /* value_table */
};
}
return type;
}
static void
{
//item_class->description = box3d_side_description;
//item_class->snappoints = box3d_side_snappoints;
//shape_class->update_patheffect = box3d_side_update_patheffect;
}
static void
{
}
static void
{
}
{
g_print ("Do we ever end up here?\n");
}
if (flags & SP_OBJECT_WRITE_EXT) {
}
/* Duplicate the path */
//Nulls might be possible if this called iteratively
if ( !curve ) {
return NULL;
}
if ( !bpath ) {
return NULL;
}
char *d = sp_svg_write_path ( bpath );
g_free (d);
return repr;
}
static void
{
// TODO: In case the box was recreated (by undo, e.g.) we need to recreate the path
// (along with other info?) from the parent box.
/* fixme: we should really collect updates */
switch (key) {
if (value) {
}
}
break;
default:
break;
}
}
static void
{
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
}
//g_print ("box3d_side_update\n");
if (flags & (SP_OBJECT_MODIFIED_FLAG |
//SP_OBJECT_CHILD_MODIFIED_FLAG |
}
}
/***
static void
box3d_side_update_patheffect(SPShape *shape, bool write)
{
box3d_side_set_shape(shape);
if (write) {
Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
if ( shape->curve != NULL ) {
NArtBpath *abp = sp_curve_first_bpath(shape->curve);
if (abp) {
gchar *str = sp_svg_write_path(abp);
repr->setAttribute("d", str);
g_free(str);
} else {
repr->setAttribute("d", "");
}
} else {
repr->setAttribute("d", NULL);
}
}
((SPObject *)shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
***/
/***
static gchar *
box3d_side_description (SPItem *item)
{
Box3DSide *side = SP_BOX3D_SIDE (item);
// while there will never be less than 3 vertices, we still need to
// make calls to ngettext because the pluralization may be different
// for various numbers >=3. The singular form is used as the index.
if (side->flatsided == false )
return g_strdup_printf (ngettext("<b>Star</b> with %d vertex",
"<b>Star</b> with %d vertices",
star->sides), star->sides);
else
return g_strdup_printf (ngettext("<b>Polygon</b> with %d vertex",
"<b>Polygon</b> with %d vertices",
star->sides), star->sides);
}
***/
void
/* This call is responsible for live update of the sides during the initial drag */
}
void
{
//g_print ("box3d_side_set_shape\n");
// avoid a warning caused by sp_document_height() (which is called from sp_item_i2d_affine() below)
// when reading a file containing 3D boxes
return;
}
g_warning ("Parent of 3D box side is not a 3D box.\n");
/**
g_print ("Removing the inkscape:box3dside attribute and returning from box3d_side_set_shape().\n");
SP_OBJECT_REPR (shape)->setAttribute("sodipodi:type", NULL);
SP_OBJECT_REPR (shape)->setAttribute("inkscape:box3dside", NULL);
**/
return;
}
//g_return_if_fail (persp != NULL);
if (!persp) {
//g_warning ("persp != NULL in box3d_side_set_shape failed!\n");
//persp = SP_OBJECT_DOCUMENT(side)->current_persp3d;
return;
}
SPCurve *c = sp_curve_new ();
// TODO: Draw the correct quadrangle here
// To do this, determine the perspective of the box, the orientation of the side (e.g., XY-FRONT)
// compute the coordinates of the corners in P^3, project them onto the canvas, and draw the
// resulting path.
// FIXME: This can better be implemented by using box3d_get_corner
sp_curve_closepath (c);
//sp_shape_perform_path_effect(c, SP_SHAPE (side));
sp_curve_unref (c);
}
static void
//box3d_side_apply_style (SPBox3D *box, bool extruded) {
/**
if (!extruded && !strcmp (box3d_side_axes_string (), "XYrear")) {
// to avoid "flashing" during the initial dragging process, we make the rear face invisible in this case
repr_face->setAttribute("style", "fill:none");
return;
}
**/
/* use last used style */
} else {
/* use default style */
}
}
gchar *
{
break;
break;
break;
default:
break;
}
}
1.0);
}
return corners;
}
/*
static gint
box3d_side_descr_to_id (gchar const *descr)
{
if (!strcmp (descr, "XYrear")) { return 5; }
if (!strcmp (descr, "XYfront")) { return 2; }
if (!strcmp (descr, "XZbottom")) { return 1; }
if (!strcmp (descr, "XZtop")) { return 4; }
if (!strcmp (descr, "YZleft")) { return 3; }
if (!strcmp (descr, "YZright")) { return 0; }
g_warning ("Invalid description of 3D box face.\n");
g_print (" (description is: %s)\n", descr);
return -1;
}
*/
Persp3D *
}
/*
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:encoding=utf-8:textwidth=99 :