compoundUpdateInputVisitor.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "compoundUpdateInputVisitor.h"
00019
00020 #include "frame.h"
00021 #include "frameData.h"
00022
00023 #include <eq/client/log.h>
00024
00025 using namespace std;
00026 using namespace stde;
00027 using namespace eq::base;
00028
00029 namespace eq
00030 {
00031 namespace server
00032 {
00033 CompoundUpdateInputVisitor::CompoundUpdateInputVisitor(
00034 const stde::hash_map<std::string, Frame*>& outputFrames )
00035 : _outputFrames( outputFrames )
00036 {}
00037
00038 VisitorResult CompoundUpdateInputVisitor::visit( Compound* compound )
00039 {
00040 if( !compound->isActive( ))
00041 return TRAVERSE_PRUNE;
00042
00043 const std::vector< Frame* >& inputFrames = compound->getInputFrames();
00044 const Channel* channel = compound->getChannel();
00045
00046 if( !compound->testInheritTask( eq::TASK_ASSEMBLE ) || !channel )
00047 return TRAVERSE_CONTINUE;
00048
00049 if( inputFrames.empty( ))
00050 {
00051 compound->unsetInheritTask( eq::TASK_ASSEMBLE );
00052 return TRAVERSE_CONTINUE;
00053 }
00054
00055 for( vector<Frame*>::const_iterator i = inputFrames.begin();
00056 i != inputFrames.end(); ++i )
00057 {
00058
00059 Frame* frame = *i;
00060 const std::string& name = frame->getName();
00061 Compound::FrameMap::const_iterator iter =_outputFrames.find( name );
00062
00063 if( iter == _outputFrames.end())
00064 {
00065 EQVERB << "Can't find matching output frame, ignoring input frame "
00066 << name << endl;
00067 frame->unsetData();
00068 continue;
00069 }
00070
00071
00072
00073 Frame* outputFrame = iter->second;
00074 const eq::Viewport& frameVP = frame->getViewport();
00075 const eq::PixelViewport& inheritPVP=compound->getInheritPixelViewport();
00076 eq::PixelViewport framePVP = inheritPVP.getSubPVP( frameVP );
00077 Vector2i frameOffset = outputFrame->getMasterData()->getOffset();
00078
00079 frameOffset += frame->getOffset();
00080
00081 if( channel != compound->getInheritChannel() &&
00082 compound->getIAttribute( Compound::IATTR_HINT_OFFSET ) != eq::ON )
00083 {
00084
00085
00086 frameOffset.x() -= framePVP.x;
00087 frameOffset.y() -= framePVP.y;
00088 }
00089 frame->setInheritOffset( frameOffset );
00090
00091
00092 _updateZoom( compound, frame, outputFrame );
00093
00094
00095
00096
00097
00098
00099
00100
00101 outputFrame->addInputFrame( frame, compound->getInheritEyes( ));
00102
00103
00104 frame->commit();
00105 EQLOG( eq::LOG_ASSEMBLY )
00106 << "Input frame \"" << name << "\" on channel \""
00107 << channel->getName() << "\" id " << frame->getID() << " v"
00108 << frame->getVersion() << "\" tile pos " << frameOffset << ' '
00109 << frame->getInheritZoom() << endl;
00110 }
00111
00112 return TRAVERSE_CONTINUE;
00113 }
00114
00115 void CompoundUpdateInputVisitor::_updateZoom( const Compound* compound,
00116 Frame* frame,
00117 const Frame* outputFrame )
00118 {
00119 Zoom zoom = frame->getZoom();
00120 if( !zoom.isValid( ))
00121 zoom = compound->getInheritZoom();
00122
00123
00124 const FrameData* frameData = outputFrame->getMasterData();
00125 zoom /= frameData->getZoom();
00126
00127 frame->setInheritZoom( zoom );
00128 }
00129
00130 }
00131 }