[opengtl-commits] [765] add nodes for alphamin, alphamax and alphaunit

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 765
Author:   cyrille
Date:     2009-05-30 12:53:13 +0200 (Sat, 30 May 2009)

Log Message:
-----------
add nodes for alphamin, alphamax and alphaunit

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
    trunk/OpenGTL/OpenCTL/tests/templates/opalpha.ctlt


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-30 10:49:36 UTC (rev 764)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-30 10:53:13 UTC (rev 765)
@@ -209,11 +209,37 @@
   if( idx == -1) {
     _context->append("1.0");
   } else {
-    _context->append( "(in_" + GTLCore::String::number(idx) + " / " +
-                      typeUnit(_context->pixelDescription().channelTypes()[idx] )  + ")" );
+    _context->append( "in_" + GTLCore::String::number(idx) );
   }
 }
 
+void AlphaMaxNode::generate(TemplateGenerationContext* _context) {
+  int idx = _context->pixelDescription().alphaPos();
+  if( idx == -1) {
+    _context->append( GTLCore::String::number(FLT_MAX) );
+  } else {
+    _context->append( typeMax( _context->pixelDescription().channelTypes()[idx] ) );
+  }
+}
+
+void AlphaMinNode::generate(TemplateGenerationContext* _context) {
+  int idx = _context->pixelDescription().alphaPos();
+  if( idx == -1) {
+    _context->append( GTLCore::String::number(FLT_MIN) );
+  } else {
+    _context->append( typeMin( _context->pixelDescription().channelTypes()[idx] ) );
+  }
+}
+
+void AlphaUnitNode::generate(TemplateGenerationContext* _context) {
+  int idx = _context->pixelDescription().alphaPos();
+  if( idx == -1) {
+    _context->append("1.0");
+  } else {
+    _context->append( typeUnit( _context->pixelDescription().channelTypes()[idx] ) );
+  }
+}
+
 InOutNode::InOutNode(Which _which) {
   switch(_which)
   {

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h	2009-05-30 10:49:36 UTC (rev 764)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h	2009-05-30 10:53:13 UTC (rev 765)
@@ -88,6 +88,18 @@
       public:
         virtual void generate(TemplateGenerationContext* _context);
     };
+    class AlphaMaxNode : public Node {
+      public:
+        virtual void generate(TemplateGenerationContext* _context);
+    };
+    class AlphaMinNode : public Node {
+      public:
+        virtual void generate(TemplateGenerationContext* _context);
+    };
+    class AlphaUnitNode : public Node {
+      public:
+        virtual void generate(TemplateGenerationContext* _context);
+    };
     class InOutNode : public Node {
       public:
         enum Which {

Modified: trunk/OpenGTL/OpenCTL/tests/templates/opalpha.ctlt
===================================================================
--- trunk/OpenGTL/OpenCTL/tests/templates/opalpha.ctlt	2009-05-30 10:49:36 UTC (rev 764)
+++ trunk/OpenGTL/OpenCTL/tests/templates/opalpha.ctlt	2009-05-30 10:53:13 UTC (rev 765)
@@ -1,5 +1,5 @@
 @operation(transformation)
 {
-  @colorchannels(@out = (@in * @alpha) );
+  @colorchannels(@out = ( (@in * @alpha) / @alphaunit) );
 ) @alphachannel(@out = @max; )
 }
\ No newline at end of file


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/