box3d.h revision 6bbadb7dace9a9325f05c20ab8401ef71e857c10
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#ifndef SEEN_SP_BOX3D_H
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#define SEEN_SP_BOX3D_H
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński/*
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * SVG <box3d> implementation
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński *
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Authors:
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Lauris Kaplinski <lauris@kaplinski.com>
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Maximilian Albert <Anhalter42@gmx.de>
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Abhishek Sharma
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński *
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Copyright (C) 2007 Authors
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Copyright (C) 1999-2002 Lauris Kaplinski
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Copyright (C) 2000-2001 Ximian, Inc.
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński *
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Released under GNU GPL, read the file 'COPYING' for more information
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński */
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#include "sp-item-group.h"
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#include "proj_pt.h"
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#include "axis-manip.h"
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#define SP_TYPE_BOX3D (box3d_get_type ())
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#define SP_BOX3D(obj) ((SPBox3D*)obj)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński#define SP_IS_BOX3D(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPBox3D)))
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskistruct Persp3D;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskiclass Persp3DReference;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskiclass CBox3D;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskiclass SPBox3D : public SPGroup {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskipublic:
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński CBox3D* cbox3d;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński gint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom)
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński gchar *persp_href;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński Persp3DReference *persp_ref;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński Proj::Pt3 orig_corner0;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński Proj::Pt3 orig_corner7;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński Proj::Pt3 save_corner0;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński Proj::Pt3 save_corner7;
d1bde559850436556ebee2e70e10f1cfc8aff636Krzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński Box3D::Axis swapped; // to indicate which coordinates are swapped during dragging
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński gint my_counter; // for debugging only
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński /**
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński * Create a SPBox3D and append it to the parent.
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński */
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński static SPBox3D * createBox3D(SPItem * parent);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński};
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskiclass SPBox3DClass {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskipublic:
d1bde559850436556ebee2e70e10f1cfc8aff636Krzysztof Kosiński SPGroupClass parent_class;
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński};
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskiclass CBox3D : public CGroup {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskipublic:
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński CBox3D(SPBox3D* box3d);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual ~CBox3D();
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual void build(SPDocument *document, Inkscape::XML::Node *repr);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual void release();
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual void set(unsigned int key, gchar const* value);
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński virtual void update(SPCtx *ctx, guint flags);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual gchar *description();
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual Geom::Affine set_transform(Geom::Affine const &transform);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński virtual void convert_to_guides();
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskiprotected:
827bc501341bcc5c344c0422f13422bc368151b4Krzysztof Kosiński SPBox3D* spbox3d;
827bc501341bcc5c344c0422f13422bc368151b4Krzysztof Kosiński};
827bc501341bcc5c344c0422f13422bc368151b4Krzysztof Kosiński
827bc501341bcc5c344c0422f13422bc368151b4Krzysztof Kosiński
827bc501341bcc5c344c0422f13422bc368151b4Krzysztof KosińskiGType box3d_get_type (void);
827bc501341bcc5c344c0422f13422bc368151b4Krzysztof Kosiński
827bc501341bcc5c344c0422f13422bc368151b4Krzysztof Kosińskivoid box3d_position_set (SPBox3D *box);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof KosińskiProj::Pt3 box3d_get_proj_corner (SPBox3D const *box, guint id);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof KosińskiGeom::Point box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords = true);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof KosińskiProj::Pt3 box3d_get_proj_center (SPBox3D *box);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof KosińskiGeom::Point box3d_get_center_screen (SPBox3D *box);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskivoid box3d_set_corner (SPBox3D *box, guint id, Geom::Point const &new_pos, Box3D::Axis movement, bool constrained);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskivoid box3d_set_center (SPBox3D *box, Geom::Point const &new_pos, Geom::Point const &old_pos, Box3D::Axis movement, bool constrained);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskivoid box3d_corners_for_PLs (const SPBox3D * box, Proj::Axis axis, Geom::Point &corner1, Geom::Point &corner2, Geom::Point &corner3, Geom::Point &corner4);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskibool box3d_recompute_z_orders (SPBox3D *box);
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosińskivoid box3d_set_z_orders (SPBox3D *box);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskiint box3d_pt_lies_in_PL_sector (SPBox3D const *box, Geom::Point const &pt, int id1, int id2, Box3D::Axis axis);
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosińskiint box3d_VP_lies_in_PL_sector (SPBox3D const *box, Proj::Axis vpdir, int id1, int id2, Box3D::Axis axis);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskivoid box3d_relabel_corners(SPBox3D *box);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskivoid box3d_check_for_swapped_coords(SPBox3D *box);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskistd::list<SPBox3D *> box3d_extract_boxes(SPObject *obj);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof KosińskiPersp3D *box3d_get_perspective(SPBox3D const *box);
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosińskivoid box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, bool recompute_corners = false);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof KosińskiSPGroup *box3d_convert_to_group(SPBox3D *box);
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński#endif // SEEN_SP_BOX3D_H
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński/*
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński Local Variables:
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński mode:c++
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński c-file-style:"stroustrup"
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński indent-tabs-mode:nil
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński fill-column:99
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński End:
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński*/
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
d6519bf53baba32bd74436ad9c85f1fa2c6b6ae9Krzysztof Kosiński