Ejemplo n.º 1
0
Color Color::add(Color c) {
    Color r;
    r.red = addChannels(red, c.red);
    r.green = addChannels(green, c.green);
    r.blue = addChannels(blue, c.blue);
    return r;
}
Ejemplo n.º 2
0
//
// the main function to get packets from AMT/SSM
int main(int argc, char *argv[])
{
    int res;
    comLine_param_t envParam;
    
    // setup environment
    res = GetEnvParam(&envParam, argc, argv);
    if (res) {
        printf("failed in getting the environment parameters\n");
        return 1;
    }
    
    // set trace; Use the external trace
    debugHost = envParam.dhost;
    amt_setTraceSink(envParam.verbose,  trace); 
    
    // call the initial function. Do nothing for now
    amt_init(envParam.anycastIP); 
    
    // add a callback function to receive all packets
    amt_addRecvHook(packetRecv, &envParam);

    // add channels
    addChannels(&envParam);
   
    return 0;
}
Ejemplo n.º 3
0
bool Mixer::addRemoteUser(ValueTree user_store , ValueTree subscriptions)
{
  // ensure GUI for this user does not already exist
  Identifier user_id = user_store.getType() ; if (getChannels(user_id)) return false ;

  // create remote user GUI
  addChannels(new RemoteChannels(user_store , subscriptions) , user_id) ;

DEBUG_TRACE_ADD_REMOTE_USER

  return true ;
}
Ejemplo n.º 4
0
//==============================================================================
Mixer::Mixer ()
{
    setName ("Mixer");

    //[UserPreSize]

  this->masterChannels   = new MasterChannels() ;
  this->localChannels    = new LocalChannels() ;
  this->prevScrollButton = new TextButton("prevScrollButton") ;
  this->nextScrollButton = new TextButton("nextScrollButton") ;
  this->localsResizer    = new ResizableEdgeComponent(this->localChannels  , nullptr ,
                                                      ResizableEdgeComponent::rightEdge) ;
  this->mastersResizer   = new ResizableEdgeComponent(this->masterChannels , nullptr ,
                                                      ResizableEdgeComponent::leftEdge) ;

  addChannels(    this->masterChannels , GUI::MASTERS_GUI_ID) ;
  addChannels(    this->localChannels  , GUI::LOCALS_GUI_ID) ;
  addScrollButton(this->prevScrollButton , "<") ;
  addScrollButton(this->nextScrollButton , ">") ;
  addResizer(     this->localsResizer) ;
  addResizer(     this->mastersResizer) ;

  this->masterChannels  ->setAlwaysOnTop(true) ;
  this->prevScrollButton->setAlwaysOnTop(true) ;
  this->nextScrollButton->setAlwaysOnTop(true) ;
  this->localsResizer   ->setAlwaysOnTop(true) ;
  this->mastersResizer  ->setAlwaysOnTop(true) ;

    //[/UserPreSize]

    setSize (622, 284);


    //[Constructor] You can add your own custom stuff here..

  this->scrollZ = 1 ;

    //[/Constructor]
}
osgAnimation::Animation* readFbxAnimation(KFbxNode* pNode,
    KFbxAnimLayer* pAnimLayer, const char* pTakeName, const char* targetName,
    osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimManager)
{
    ERotationOrder rotOrder = pNode->RotationOrder.IsValid() ? pNode->RotationOrder.Get() : eEULER_XYZ;

    osgAnimation::Channel* pTranslationChannel = 0;
    osgAnimation::Channel* pRotationChannel = 0;

    if (pNode->LclRotation.IsValid())
    {
        fbxDouble3 fbxBaseValue = pNode->LclRotation.Get();

        pRotationChannel = readFbxChannelsQuat(
            pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_X),
            pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_Y),
            pNode->LclRotation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_R_Z),
            pNode->LclRotation.Get(),
            targetName, rotOrder);
    }

    if (pNode->LclTranslation.IsValid())
    {
        pTranslationChannel = readFbxChannels(
            pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_X),
            pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_Y),
            pNode->LclTranslation.GetCurve<KFbxAnimCurve>(pAnimLayer, KFCURVENODE_T_Z),
            pNode->LclTranslation.Get(),
            targetName, "translate");
    }

    osgAnimation::Channel* pScaleChannel = readFbxChannels(
        pNode->LclScaling, pAnimLayer, targetName, "scale");

    return addChannels(pTranslationChannel, pRotationChannel, pScaleChannel, pAnimManager, pTakeName);
}
Ejemplo n.º 6
0
osgAnimation::Animation* readFbxAnimation(FbxNode* pNode,
    FbxAnimLayer* pAnimLayer, const char* pTakeName, const char* targetName,
    osg::ref_ptr<osgAnimation::AnimationManagerBase>& pAnimManager)
{
    osgAnimation::Channel* pTranslationChannel = 0;
    osgAnimation::Channel* pRotationChannels[3] = {0};
    readFbxRotationAnimation(pRotationChannels, pNode, pAnimLayer, targetName);


    if (pNode->LclTranslation.IsValid())
    {
        pTranslationChannel = readFbxChannels(
            pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_X),
            pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y),
            pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z),
            pNode->LclTranslation.Get(),
            targetName, "translate");
    }

    osgAnimation::Channel* pScaleChannel = readFbxChannels(
        pNode->LclScaling, pAnimLayer, targetName, "scale");

    return addChannels(pTranslationChannel, pRotationChannels, pScaleChannel, pAnimManager, pTakeName);
}
Ejemplo n.º 7
0
int main(int argc, char** argv) {

    float** testRedChannel = generateImageArray("red.txt");
    float** testGreenChannel = generateImageArray("green.txt");
    float** testBlueChannel = generateImageArray("blue.txt");

    int h = getImageWidth("red.txt");
    int w = getImageHeight("red.txt");
    printf("%i rows x %i columns\n", h, w);

    ///////////////////////////////////////////////////////////
    //////Compute the l1-norm distance of neighbor pixels./////
    ///////////////////////////////////////////////////////////

    float** dIcdxRed = diffH(testRedChannel, h,w);
    float** dIcdxGreen = diffH(testGreenChannel, h,w);
    float** dIcdxBlue = diffH(testBlueChannel, h,w);

    float** dIcdx = addChannels(dIcdxRed, dIcdxGreen, dIcdxBlue, h,w);
    destroyArray(dIcdxRed);
    destroyArray(dIcdxGreen);
    destroyArray(dIcdxBlue);

    float** dIcdyRed = diffV(testRedChannel, h,w);
    float** dIcdyGreen = diffV(testGreenChannel, h,w);
    float** dIcdyBlue = diffV(testBlueChannel, h,w);

    float** dIcdy = addChannels(dIcdyRed, dIcdyGreen, dIcdyBlue, h,w);
    destroyArray(dIcdyRed);
    destroyArray(dIcdyGreen);
    destroyArray(dIcdyBlue);

    ///////////////////////////////////////////////////////////
    ///////Compute the derivatives of the horizontal///////////
    ///////and vertical domain transforms./////////////////////
    ///////////////////////////////////////////////////////////

    float factor = sigma_s / sigma_r;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dIcdx[i][j] = 1 + factor * dIcdx[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dIcdy[i][j] = 1 + factor * dIcdy[i][j];
        }
    }
    ///The vertical pass is performed using a transposed image.
    float** dHdyT = transpose(dIcdy, h, w);
    destroyArray(dIcdy);

    ///////////////////////////////////////////////////////////
    ///////////////////Perform the filtering.//////////////////
    ///////////////////////////////////////////////////////////

    filtering(testRedChannel, dIcdx, dHdyT, h, w, 10);
    filtering(testGreenChannel, dIcdx, dHdyT, h, w, 10);
    filtering(testBlueChannel, dIcdx, dHdyT, h, w, 10);

    ///////////////////////////////////////////////////////////
    ///////////////////GENERATE OUTPUT IMAGE///////////////////
    ///////////////////////////////////////////////////////////

    generateImageFile(testRedChannel, "outred.txt", h, w);
    generateImageFile(testGreenChannel, "outgreen.txt", h, w);
    generateImageFile(testBlueChannel, "outblue.txt", h, w);

    ///////////////////////////////////////////////////////////
    ///////////////////////FREE MEMORY/////////////////////////
    ///////////////////////////////////////////////////////////

    destroyArray(dIcdx);
    destroyArray(dHdyT);
    destroyArray(testRedChannel);
    destroyArray(testGreenChannel);
    destroyArray(testBlueChannel);
    return 0;
}
Ejemplo n.º 8
0
/******************************************************************************
 * Slot called when the Load button has been clicked.
 *
 * Open a user interface dialog to load a transfer function.
 * Currently, format is XML document.
 ******************************************************************************/
void Qtfe::onLoadButtonClicked()
{
	// TO DO
	// Add a mecanism to check the format of the file while parsing
	// ...

	// Open a user interface dialog to load file
	QString name = QFileDialog::getOpenFileName( 0, QString(), QString(), "*.xml" );
	if ( name.isEmpty() )
	{
		return;
	}

	// Update member variables
	_filename = name;
	_filenameLineEdit->setText( _filename );

	// Try to open/create file
	QFile file( _filename );
	if ( ! file.open( QIODevice::ReadOnly ) )
	{
		// TO DO
		// Handle error
		//...

		return;
	}

	// Load file data in memory
	QDomDocument doc;
	if ( ! doc.setContent( &file ) )
	{
		// TO DO
		// Handle error
		//...

		file.close();

		return;
	}
	file.close();

	// Block functionChanged() signal while loading
	blockSignals( true );

	// Iterate through channels and destroy them
	for ( int i = 0; i < _channels.size(); ++i )
	{
		delete _channels[ i ];
	}
	_channels.clear();

	// Iterate through outputs and destroy them
	for ( int i = 0; i < _outputs.size(); ++i )
	{
		delete _outputs[ i ];
	}
	_outputs.clear();

	// Traverse the XML document
	QDomElement root = doc.documentElement();
	QDomNode node = root.firstChild();
	while( ! node.isNull() )
	{
		QDomElement element = node.toElement();

		// Search for channels
		if ( element.tagName() == "Function" )
		{
			// Create a new channel
			addChannels( 1 );

			// Retrieve list of points of current channel
			QDomNodeList points = element.childNodes();

			// Set first and last points of newly created channel
			QtfeChannel* channel = _channels.back();
			channel->setFirstPoint( points.item( 0 ).toElement().attributeNode( "y" ).value().toDouble() );
			channel->setLastPoint( points.item( points.length() - 1 ).toElement().attributeNode( "y" ).value().toDouble() );

			// Iterate through points and add intermediate points to newly created channel
			for ( uint i = 1; i < points.length() - 1; i++ )
			{
				// Retrieve current point
				QDomNode point = points.item( i );

				// Retrieve x and y values
				qreal x = point.toElement().attributeNode( "x" ).value().toDouble();
				qreal y = point.toElement().attributeNode( "y" ).value().toDouble();
		
				// Add point in channel
				channel->insertPoint( QPointF( x, y ) );
			}
		}

		// Search for outputs
		if ( element.tagName() == "Output" )
		{
			// Create a new output
			QtfeOutput* output = new QtfeOutput( this );

			// Do bindings
			output->bindChannelToR( element.attributeNode( "R" ).value().toInt() );	
			output->bindChannelToG( element.attributeNode( "G" ).value().toInt() );
			output->bindChannelToB( element.attributeNode( "B" ).value().toInt() );
			output->bindChannelToA( element.attributeNode( "A" ).value().toInt() );
			
			// Store the output
			_outputs.push_back( output );
			
			// Add it to main widget
			//this->layout()->addWidget( output );
			_transferFunctionGroupBox->layout()->addWidget( output );

			// Do connection(s)
			QObject::connect( output, SIGNAL( outputBindingChanged() ), this, SLOT( onOutputBindingChanged() ) );
		}

		// Go to next sibling in order to traverse the XML document
		node = node.nextSibling();
	}

	// Unblock functionChanged() signal
	blockSignals( false );

	// Emit signal
	emit functionChanged();
}