home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / include / k3d / k3dsdk / transformable.h < prev    next >
C/C++ Source or Header  |  2008-12-16  |  2KB  |  75 lines

  1. #ifndef K3DSDK_TRANSFORMABLE_H
  2. #define K3DSDK_TRANSFORMABLE_H
  3.  
  4. // K-3D
  5. // Copyright (c) 1995-2005, Timothy M. Shead
  6. //
  7. // Contact: tshead@k-3d.com
  8. //
  9. // This program is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. // General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public
  20. // License along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. /** \file
  24.         \author Tim Shead (tshead@k-3d.com)
  25. */
  26.  
  27. #include "algebra.h"
  28. #include "data.h"
  29. #include "itransform_sink.h"
  30. #include "itransform_source.h"
  31.  
  32. namespace k3d
  33. {
  34.  
  35. /// Provides a boilerplate implementation of an object that can act as a transform source and a transform sink
  36. template<typename base_t>
  37. class transformable :
  38.     public base_t,
  39.     public itransform_source,
  40.     public itransform_sink
  41. {
  42. public:
  43.     transformable(iplugin_factory& Factory, idocument& Document) :
  44.         base_t(Factory, Document),
  45.         m_input_matrix(init_owner(*this) + init_name("input_matrix") + init_label(_("Input Matrix")) + init_description("Input matrix") + init_value(identity3())),
  46.         m_output_matrix(init_owner(*this) + init_name("output_matrix") + init_label(_("Output Matrix")) + init_description(_("Output Matrix")) + init_slot(sigc::mem_fun(*this, &transformable<base_t>::matrix)))
  47.     {
  48.         m_input_matrix.changed_signal().connect(m_output_matrix.make_reset_slot());
  49.     }
  50.  
  51.     iproperty& transform_source_output()
  52.     {
  53.         return m_output_matrix;
  54.     }
  55.  
  56.     iproperty& transform_sink_input()
  57.     {
  58.         return m_input_matrix;
  59.     }
  60.  
  61. protected:
  62.     virtual matrix4 matrix()
  63.     {
  64.         return m_input_matrix.pipeline_value();
  65.     }
  66.  
  67.     k3d_data(matrix4, data::immutable_name, data::change_signal, data::no_undo, data::local_storage, data::no_constraint, data::writable_property, data::with_serialization) m_input_matrix;
  68.     k3d_data(matrix4, data::immutable_name, data::change_signal, data::no_undo, data::computed_storage, data::no_constraint, data::read_only_property, data::no_serialization) m_output_matrix;
  69. };
  70.  
  71. } // namespace k3d
  72.  
  73. #endif // !K3DSDK_TRANSFORMABLE_H
  74.  
  75.