[opengtl-commits] [735] make AllChannelsNode works for @allchannels, @colorchannels and @ alphachannel

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


Revision: 735
Author:   cyrille
Date:     2009-05-26 10:09:00 +0200 (Tue, 26 May 2009)

Log Message:
-----------
make AllChannelsNode works for @allchannels, @colorchannels and @alphachannel

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-26 07:50:42 UTC (rev 734)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-26 08:09:00 UTC (rev 735)
@@ -112,7 +112,7 @@
   _context->startOperation();
 }
 
-AllChannelsNode::AllChannelsNode( NodesList* _nodesList ) : m_nodesList(_nodesList) {
+AllChannelsNode::AllChannelsNode( NodesList* _nodesList, WhichChannel _whichChannel ) : m_nodesList(_nodesList), m_whichChannel(_whichChannel) {
 }
 
 AllChannelsNode::~AllChannelsNode() {
@@ -123,8 +123,14 @@
   const GTLCore::PixelDescription& pd = _context->pixelDescription();
   for(std::size_t i = 0; i < pd.channels(); ++i)
   {
-    TemplateGenerationContext* localContext = _context->createLocalContext(GTLCore::String::number(i));
-    m_nodesList->generate(localContext);
-    _context->mergeLocalContext(localContext);
+    if( m_whichChannel == AllChannel
+        or ( m_whichChannel == ColorChannel and i != pd.alphaPos() )
+        or ( m_whichChannel == AlphaChannel and i == pd.alphaPos() ) )
+    {
+      TemplateGenerationContext* localContext = _context->createLocalContext(GTLCore::String::number(i));
+      m_nodesList->generate(localContext);
+      _context->mergeLocalContext(localContext);
+    }
   }
 }
+

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h	2009-05-26 07:50:42 UTC (rev 734)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h	2009-05-26 08:09:00 UTC (rev 735)
@@ -68,16 +68,19 @@
     };
     class AllChannelsNode : public Node {
       public:
-        AllChannelsNode( NodesList* _nodesList );
+        enum WhichChannel {
+          ColorChannel = 1,
+          AlphaChannel = 2,
+          AllChannel = ColorChannel | AlphaChannel
+        };
+      public:
+        AllChannelsNode( NodesList* _nodesList, WhichChannel _whichChannel );
         virtual ~AllChannelsNode();
         virtual void generate(TemplateGenerationContext* _context);
       private:
         NodesList* m_nodesList;
+        WhichChannel m_whichChannel;
     };
-    class ColorChannelsNode : public Node {
-      public:
-        virtual void generate(TemplateGenerationContext* _context);
-    };
     class OutNode : public Node {
       public:
         virtual void generate(TemplateGenerationContext* _context);


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