Added copyright lines for files I've edited this year.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_stripes.cpp
index 048025f..424a73d 100644 (file)
@@ -1,20 +1,22 @@
 /* === S Y N F I G ========================================================= */
-/*!    \file valuenode_subtract.cpp
-**     \brief Template File
+/*!    \file valuenode_stripes.cpp
+**     \brief Implementation of the "Stripes" valuenode conversion.
 **
-**     $Id: valuenode_stripes.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
+**     $Id$
 **
 **     \legal
-**     Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
 **
-**     This software and associated documentation
-**     are CONFIDENTIAL and PROPRIETARY property of
-**     the above-mentioned copyright holder.
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
 **
-**     You may not copy, print, publish, or in any
-**     other way distribute this software without
-**     a prior written agreement with
-**     the copyright holder.
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
 **     \endlegal
 */
 /* ========================================================================= */
@@ -69,17 +71,17 @@ ValueNode_Stripes*
 ValueNode_Stripes::create(const ValueBase& x)
 {
        ValueBase::Type id(x.get_type());
-       
+
        if(id!=ValueBase::TYPE_GRADIENT)
        {
                assert(0);
-               throw runtime_error("synfig::ValueNode_Stripes:Bad type "+ValueBase::type_name(id));                    
-       }               
+               throw runtime_error(String(_("Stripes"))+_(":Bad type ")+ValueBase::type_local_name(id));
+       }
 
        ValueNode_Stripes* value_node=new ValueNode_Stripes();
 
        assert(value_node->get_type()==id);
-       
+
        return value_node;
 }
 
@@ -88,52 +90,10 @@ synfig::ValueNode_Stripes::~ValueNode_Stripes()
        unlink_all();
 }
 
-bool
-synfig::ValueNode_Stripes::set_color1(ValueNode::Handle a)
-{
-       if(a->get_type()!=ValueBase::TYPE_COLOR)
-               return false;
-
-       color1_=a;
-
-       return true;
-}
-
-bool
-synfig::ValueNode_Stripes::set_color2(ValueNode::Handle a)
-{
-       if(a->get_type()!=ValueBase::TYPE_COLOR)
-               return false;
-
-       color2_=a;
-
-       return true;
-}
-
-bool
-synfig::ValueNode_Stripes::set_width(ValueNode::Handle x)
-{
-       if(x->get_type()!=ValueBase::TYPE_REAL)
-               return false;
-
-       width_=x;
-
-       return true;
-}
-
-bool
-synfig::ValueNode_Stripes::set_stripes(ValueNode::Handle b)
-{
-       if(b->get_type()!=ValueBase::TYPE_INTEGER)
-               return false;
-       stripes_=b;
-       return true;
-}
-
 synfig::ValueBase
 synfig::ValueNode_Stripes::operator()(Time t)const
 {
-       const int total((*stripes_)(t).get(int()));             
+       const int total((*stripes_)(t).get(int()));
        int i;
        Gradient ret;
 
@@ -143,10 +103,10 @@ synfig::ValueNode_Stripes::operator()(Time t)const
        const Color color1((*color1_)(t).get(Color()));
        const Color color2((*color2_)(t).get(Color()));
        const float width(max(0.0,min(1.0,(*width_)(t).get(Real()))));
-       
+
        const float stripe_width_a(width/total);
        const float stripe_width_b((1.0-width)/total);
-       
+
        for(i=0;i<total;i++)
        {
                float pos(float(i)/total+stripe_width_b/2);
@@ -160,25 +120,17 @@ synfig::ValueNode_Stripes::operator()(Time t)const
 }
 
 bool
-ValueNode_Stripes::set_link_vfunc(int i,ValueNode::Handle x)
+ValueNode_Stripes::set_link_vfunc(int i,ValueNode::Handle value)
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
-               case 0:
-                       if(set_color1(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
-                       else { return false; }
-               case 1:
-                       if(set_color2(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
-                       else { return false; }
-               case 2:
-                       if(set_stripes(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
-                       else { return false; }
-               case 3:
-                       if(set_width(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
-                       else { return false; }
+       case 0: CHECK_TYPE_AND_SET_VALUE(color1_,  ValueBase::TYPE_COLOR);
+       case 1: CHECK_TYPE_AND_SET_VALUE(color2_,  ValueBase::TYPE_COLOR);
+       case 2: CHECK_TYPE_AND_SET_VALUE(stripes_, ValueBase::TYPE_INTEGER);
+       case 3: CHECK_TYPE_AND_SET_VALUE(width_,   ValueBase::TYPE_REAL);
        }
-
        return false;
 }
 
@@ -186,6 +138,7 @@ ValueNode::LooseHandle
 ValueNode_Stripes::get_link_vfunc(int i)const
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
                case 0:
@@ -210,6 +163,7 @@ String
 ValueNode_Stripes::link_local_name(int i)const
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
                case 0:
@@ -220,14 +174,16 @@ ValueNode_Stripes::link_local_name(int i)const
                        return _("Stripe Count");
                case 3:
                        return _("Width");
+               default:
+                       return String();
        }
-       return String();
-}      
+}
 
 String
 ValueNode_Stripes::link_name(int i)const
 {
        assert(i>=0 && i<link_count());
+
        switch(i)
        {
                case 0:
@@ -238,9 +194,10 @@ ValueNode_Stripes::link_name(int i)const
                        return "stripes";
                case 3:
                        return "width";
+               default:
+                       return String();
        }
-       return String();
-}      
+}
 
 int
 ValueNode_Stripes::get_link_index_from_name(const String &name)const