box3d.cpp revision d81a973b81c26fcef48f46fc665eef88d386af07
#define __SP_3DBOX_C__
/*
* SVG <box3d> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Maximilian Albert <Anhalter42@gmx.de>
*
* Copyright (C) 2007 Authors
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "attributes.h"
#include "svg/stringstream.h"
#include "box3d.h"
static Inkscape::XML::Node *sp_3dbox_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
//static void sp_3dbox_set_shape(SPShape *shape);
static void sp_3dbox_update_corner_with_value_from_svg (SPObject *object, guint corner_id, const gchar *value);
static SPGroupClass *parent_class;
sp_3dbox_get_type(void)
{
if (!type) {
sizeof(SP3DBoxClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof(SP3DBox),
16, /* n_preallocs */
NULL, /* value_table */
};
}
return type;
}
static void
{
}
static void
{
}
static void
{
}
// TODO: We create all faces in the beginning, but only the non-degenerate ones
// should be written to the svg representation later in sp_3dbox_write.
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 2; ++j) {
// FIXME: The following code could theoretically be moved to
// the constructor of Box3DFace (but see the comment there).
}
}
// Check whether the paths of the faces of the box need to be linked to existing paths in the
// document (e.g., after a 'redo' operation or after opening a file) and do so if necessary.
}
static void
{
for (int i = 0; i < 6; ++i) {
}
}
// FIXME: We do not duplicate perspectives if they are the same for several boxes.
// Thus, don't delete the perspective when deleting a box but rather unlink the box from it.
}
}
{
switch (key) {
break;
break;
break;
default:
}
break;
}
}
static void
{
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
}
/* Invoke parent method */
}
static Inkscape::XML::Node *sp_3dbox_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
{
// FIXME: How to handle other contexts???
return repr;
/* Hook paths to the faces of the box */
for (int i = 0; i < 6; ++i) {
}
}
for (int i = 0; i < 6; ++i) {
}
if (flags & SP_OBJECT_WRITE_EXT) {
}
}
return repr;
}
static gchar *
{
return g_strdup(_("<b>3D Box</b>"));
}
void
{
// FIXME: Why does the following call not automatically update the children
// of box3d (which is an SPGroup, which should do this)?
//SP_OBJECT(box3d)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
/**
SP_OBJECT(box3d->path_face1)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
SP_OBJECT(box3d->path_face2)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
SP_OBJECT(box3d->path_face3)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
SP_OBJECT(box3d->path_face4)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
SP_OBJECT(box3d->path_face5)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
SP_OBJECT(box3d->path_face6)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
***/
}
static void
// FIXME: Note that this is _not_ the virtual set_shape() method inherited from SPShape,
// since SP3DBox is inherited from SPGroup. The following method is "artificially"
// called from sp_3dbox_update().
//sp_3dbox_set_shape(SPShape *shape)
{
// FIXME: How to handle other contexts???
return;
/* Only update the curves during dragging; setting the svg representations
is expensive and only done once at the end */
box3d->faces[0]->set_corners (box3d->corners[0], box3d->corners[4], box3d->corners[6], box3d->corners[2]);
box3d->faces[1]->set_corners (box3d->corners[1], box3d->corners[5], box3d->corners[7], box3d->corners[3]);
box3d->faces[2]->set_corners (box3d->corners[0], box3d->corners[1], box3d->corners[5], box3d->corners[4]);
box3d->faces[3]->set_corners (box3d->corners[2], box3d->corners[3], box3d->corners[7], box3d->corners[6]);
box3d->faces[5]->set_corners (box3d->corners[4], box3d->corners[5], box3d->corners[7], box3d->corners[6]);
}
box3d->faces[4]->set_corners (box3d->corners[0], box3d->corners[1], box3d->corners[3], box3d->corners[2]);
}
void sp_3dbox_recompute_corners (SP3DBox *box, NR::Point const A, NR::Point const B, NR::Point const C)
{
}
void
for (int i = 0; i < 6; ++i) {
}
}
/**
* In some situations (e.g., after cloning boxes, undo & redo, or reading boxes from a file) there are
* paths already present in the document which correspond to the faces of newly created boxes, but their
* 'path' members don't link to them yet. The following function corrects this if necessary.
*/
void
// TODO: We should probably destroy the existing paths and recreate them because we don't know
// precisely which path corresponds to which face. Does this make a difference?
// In sp_3dbox_write we write the correct paths anyway, don't we? But we could get into
// trouble at a later stage when we only write single faces for degenerate boxes.
if (face_id > 5) {
g_warning ("SVG representation of 3D boxes must contain 6 paths or less.\n");
break;
}
if (!SP_IS_PATH(face_object)) {
g_warning ("SVG representation of 3D boxes should only contain paths.\n");
continue;
}
++face_id;
}
if (face_id < 6) {
//g_warning ("SVG representation of 3D boxes should contain exactly 6 paths (degenerate boxes are not yet supported).\n");
// TODO: Check whether it is safe to add the remaining paths to the box and do so in case it is.
// (But we also land here for newly created boxes where we shouldn't add any paths because
// This is done in sp_3dbox_write later on.
}
}
void
{
}
/* set the 'front' corners */
/* set the 'rear' corners */
}
void
{
/* set the four corners of the face containing corners[id] */
}
{
}
{
// Is all this sufficiently precise also for degenerate cases?
} else {
}
}
static gchar *
{
}
{
// We might as well rely on g_ascii_strtod to convert the NULL pointer to 0.0,
// but we include the following test anyway
g_warning ("Coordinate conversion failed.\n");
}
}
// auxiliary function
static void
{
}
/*
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 :