示例#1
0
void
Connection::
setGraphicsObject(std::unique_ptr<ConnectionGraphicsObject>&& graphics)
{
  _connectionGraphicsObject = std::move(graphics);

  // This function is only called when the ConnectionGraphicsObject
  // is newly created. At this moment both end coordinates are (0, 0)
  // in Connection G.O. coordinates. The position of the whole
  // Connection G. O. in scene coordinate system is also (0, 0).
  // By moving the whole object to the Node Port position
  // we position both connection ends correctly.

  PortType attachedPort = oppositePort(requiredPort());

  PortIndex attachedPortIndex = getPortIndex(attachedPort);

  std::shared_ptr<Node> node = getNode(attachedPort).lock();

  QTransform nodeSceneTransform =
    node->nodeGraphicsObject()->sceneTransform();

  QPointF pos = node->nodeGeometry().portScenePosition(attachedPortIndex,
                                                       attachedPort,
                                                       nodeSceneTransform);

  _connectionGraphicsObject->setPos(pos);
}
示例#2
0
文件: midi4l.cpp 项目: aumhaa/MIDI4L
 /**
  * Set the output port by name.
  * If the name is valid, this object will pass messages received to it's first inlet to the MIDI port.
  * If the name is invalid, an error is printed to the Max console and nothing else happens.
  * As a special behavior, sending the [outport " "] message will close the port. This plays nice with the way we build the umenu port list.
  */
 void output(long inlet, t_symbol *s, long ac, t_atom *av) {
     t_symbol *portName = _sym_nothing;
     
     // TODO: maybe handle ints (and floats cast to int) and use it to lookup a port by index.
     // Could be a useful for someone with devices with duplicate names.
     // See simplemax_new for an example of how to check the atom type
     
     if( atom_arg_getsym(&portName, 0, ac, av) == MAX_ERR_NONE ) {
         if (midiout) {
             int portIndex = getPortIndex(outPortMap, portName);
             
             if(portIndex >= 0 || portName == SYM_NONE) {
                 midiout->closePort();
                 outPortName = NULL;
             }
             
             if(portIndex >= 0) {
                 midiout->openPort( portIndex );
                 // TODO? midiout->setErrorCallback()
                 outPortName = portName;
             }
             else if(portName != SYM_NONE) {
                 object_error((t_object *)this, "Output port not found: %s", *portName);
             }
         }
         // else we already printed an error in the constructor
     }
     else {
         object_error((t_object *)this, "Invalid output. A portname is required. Or use (output <none>) to close the port.");
     }
 }
WOM_API OMX_ERRORTYPE Wom_PortVideo::setFormatInPortDefinition(const OMX_PARAM_PORTDEFINITIONTYPE &portdef)
//*************************************************************************************************************
{
	OMX_ERRORTYPE error=OMX_ErrorNone;
	OMX_VIDEO_PORTDEFINITIONTYPE &Video=mParamPortDefinition.format.video;
	Video = portdef.format.video;

	// NB: Camera ports definition will remain of video type.
	if (portdef.eDomain==OMX_PortDomainVideo)
	{ //make a normal copy
		mParamPortDefinition.eDomain = OMX_PortDomainVideo; //Stay in video
		Video = portdef.format.video;
	}
	else if (portdef.eDomain==OMX_PortDomainImage)
	{ //Make a morphing to video domain
		mParamPortDefinition.eDomain = OMX_PortDomainVideo; //Stay in video
		Video.cMIMEType              = portdef.format.image.cMIMEType;
		Video.pNativeRender          = portdef.format.image.pNativeRender;
		Video.nFrameWidth            = portdef.format.image.nFrameWidth;
		Video.nFrameHeight           = portdef.format.image.nFrameHeight;
		Video.nStride                = portdef.format.image.nStride;
		Video.nSliceHeight           = portdef.format.image.nSliceHeight; //This is NO MORE areadonly field
		Video.nBitrate               = 0;
		Video.xFramerate             = 0;
		Video.bFlagErrorConcealment  = portdef.format.image.bFlagErrorConcealment;
		Video.eCompressionFormat     = (OMX_VIDEO_CODINGTYPE)portdef.format.image.eCompressionFormat;
		Video.eColorFormat           = portdef.format.image.eColorFormat;
		Video.pNativeWindow          = portdef.format.image.pNativeWindow;
	}
	else
	{
		error=OMX_ErrorBadParameter;
	}

	if (Video.nSliceHeight < Video.nFrameHeight)
	{
		// MSG1("Update SliceHeight to %u\n", (unsigned int)Video.nFrameHeight);
		Video.nSliceHeight= Video.nFrameHeight;
	}


	if (Video.nSliceHeight < Video.nFrameHeight)
	{
		// MSG2("Invalid SliceHeight=%u and nFrameHeight=%u\n", (unsigned int)Video.nSliceHeight, (unsigned int)Video.nFrameHeight);
		Video.nSliceHeight= Video.nFrameHeight;
		error=OMX_ErrorBadParameter;
	}

	const _sImageFormatDescription* pFormatDesc= GetImageFormatDescription(Video.eColorFormat);
	WOM_ASSERT(pFormatDesc);
	OMX_U32 ComputedBufferSize=0;
	if(( pFormatDesc!=NULL) && ( pFormatDesc->NbPlan!=0) )
	{ //Known format

		int ComputedStride=(int) (pFormatDesc->PixelDepth0 * Video.nFrameWidth);
		if (Video.nStride <=0)
		{ //automatic stride
			Video.nStride=ComputedStride;
		}
		if ( Video.nStride < ComputedStride)
		{ //Invalid stride take right one
			error=OMX_ErrorBadParameter;
			Video.nStride=ComputedStride;
		}
		m_ImageInfo.pFormatDescription= pFormatDesc;
		m_ImageInfo.StrideInPixel     = (int) (Video.nStride / pFormatDesc->PixelDepth0);
		m_ImageInfo.ImageSize         = (int) ((Video.nStride * Video./*nFrameHeight*/nSliceHeight * pFormatDesc->OverallPixelDepth) / pFormatDesc->PixelDepth0);
		ComputedBufferSize= m_ImageInfo.ImageSize;
	}
	else
	{ //Invalid format
		//Compute pixel depth and stride using default parameters
		WOM_ASSERT(0);
		if(( pFormatDesc!=NULL) && (pFormatDesc->Name!=NULL))
		{
			//Component.ReportError(-1, "Port[%d]  format '%s'=%d is NOT supported\n", getPortIndex(), pFormatDesc->Name , Video.eColorFormat);
		}
		else
		{
			//Component.ReportError(-1, "Port[%d]  format %d is NOT supported\n", getPortIndex(), Video.eColorFormat);
		}
		error=OMX_ErrorFormatNotDetected;
		m_ImageInfo.Init();

		float bytesPerPixel = 3.; //Take biggest one
		int ComputedStride=(int) (bytesPerPixel * Video.nFrameWidth);
		if (Video.nStride <=0)
		{ //automatic stride
			Video.nStride=ComputedStride;
		}
	#if 0
		else if (ComputedStride > Video.nStride)
		{ //Given ComputedStride is invalid for this format
			Video.nStride=ComputedStride; //fix the stride to minimal value
			ImgEns_Component& Component=(ImgEns_Component&)getENSComponent();
			Component.ReportError(OMX_ErrorBadParameter, "Stride to small for port[%d]", getPortIndex());
			error=OMX_ErrorBadParameter;
		}
	#endif
		ComputedBufferSize = (OMX_U32) ( bytesPerPixel * Video.nFrameWidth * Video./*nFrameHeight*/nSliceHeight);
	}

	if (ComputedBufferSize != 0)
	{
		//ER Bug with external splitter when extradata space has been added to input port
		if ((mParamPortDefinition.eDir==OMX_DirOutput) || (m_bReserveExtradataForInput==true))
		{ //For the moment add extradata more space ....
			ComputedBufferSize += EXTRADATA_STILLPACKSIZE;
		}
		if (ComputedBufferSize == 0)
		{
			// MSG0("Calculated a NULL buffer size ! This should not occur \n");
			error=OMX_ErrorFormatNotDetected;
		}
		mParamPortDefinition.nBufferSize = ComputedBufferSize;
	}
	else
	{ ///Keep current size...
		//ImgEns_Component& Component=(ImgEns_Component&)getENSComponent();
		//Component.ReportError(-1, "Port[%d] Compute a null size", getPortIndex());
		error=OMX_ErrorBadParameter;
	}

	//Inform the component that port settings change
/* LR_CHANGE a remettre
	if( m_Omx_Component.PortFormatChanged(*this)!=S_OK)
		error=OMX_ErrorUnsupportedSetting;
*/
	return error;
}