Example #1
0
void UpdateProxyView(GPtr globals)
{
	// Get some local memory for our display
	// If we have valid pointers then just reuse
	long memorySize = 1;
	long channelSize = (gProxyRect.bottom - gProxyRect.top) 
		             * (gProxyRect.right - gProxyRect.left);
	memorySize *= channelSize;
	memorySize *= NumberOfChannels(globals);

	if (gChannelData == NULL)
	{
		gChannelData = gPSBufferSuite64->New(NULL, memorySize);
		if (gChannelData == NULL)
		{
			gResult = memFullErr;
			return;
		}
	}

	ReadChannelDesc *pChannel = NULL;
	char *pLayerData = NULL;
	short channelCount = 0;

	// figure out what channel(s) we are trying to manipulate
	if (gViewLayerIndex == 0)
	{
		if (gViewAllLayerData)
			pChannel = gDocDesc->mergedCompositeChannels;
		else
			pChannel = gDocDesc->targetCompositeChannels;
	}
	else
	{
		int16 index = gViewLayerIndex - 1;
		ReadLayerDesc * layerDesc = gDocDesc->layersDescriptor;
		while (index && layerDesc != NULL)
		{	
			layerDesc = layerDesc->next;
			index--;
		}

		if (layerDesc != NULL)
			pChannel = layerDesc->compositeChannelsList;
	}
		
	// we may have a multichannel document
	if (pChannel == NULL)
		pChannel = gDocDesc->alphaChannels;

	// figure out the rectangle of "Hello World " in proxy space
	Rect outRect;
	outRect.top = (short)(gPointV / gScaleFactor);
	outRect.left = (short)(gPointH / gScaleFactor);
	outRect.bottom = (short)(outRect.top + VSIZE / gScaleFactor * gXFactor);
	outRect.right = (short)(outRect.left + HSIZE / gScaleFactor * gXFactor);
	
	// gChannelData holds all the channels, so adjust the starting point
	// accordingly. The Gaussian Blur effect is a little off in the proxy view
	// because the data is scaled down for the effect.
	while (pChannel != NULL && gResult == 0)
	{
		pLayerData = gChannelData + channelSize * channelCount++;
		ReadLayerData(globals, pChannel, pLayerData, true);
		HelloWorldData(pLayerData, &outRect, &gProxyRect);
		if (gGaussianBlurData)
			GaussianBlurEffect(globals, &outRect, &gProxyRect, pLayerData);
		pChannel = pChannel->next;
	}

	// Rest of the channels hold less data
	memorySize /= NumberOfChannels(globals);

	// are we showing another layer, all the merged channels or just the target
	if (gViewLayerIndex == 0)
	{
		if (gViewAllLayerData)
			pChannel = gDocDesc->mergedTransparency;
		else
			pChannel = gDocDesc->targetTransparency;
	}
	else
	{
		int16 index = gViewLayerIndex - 1;
		ReadLayerDesc * layerDesc = gDocDesc->layersDescriptor;
		while (index && layerDesc != NULL)
		{	
			layerDesc = layerDesc->next;
			index--;
		}

		if (layerDesc != NULL)
			pChannel = layerDesc->transparency;
	}

	if (pChannel != NULL)
	{
		if (gMaskData == NULL)
		{
			gMaskData = gPSBufferSuite64->New(NULL, memorySize);
			if (gMaskData == NULL)
			{
				gResult = memFullErr;
				return;
			}
		}

		// Read in the mask and set it so we can see the channels
		ReadLayerData(globals, pChannel, gMaskData, true);
		HelloWorldMaskData(gMaskData, &outRect, &gProxyRect, false);
	}

	// Do we have a selection, I don't do anything with it except in the proxy view
	// I ignore the selection when actually doing the effect. You may want to add
	// additional logic to not do this.
	if (gDocDesc->selection != NULL)
	{
		if (gSelectionData == NULL)
		{
			gSelectionData = gPSBufferSuite64->New(NULL, memorySize);
			if (gSelectionData == NULL)
			{
				gResult = memFullErr;
				return;
			}
		}

		ReadLayerData(globals, gDocDesc->selection, gSelectionData, true);
	}

	// Make the selection look like a mask
	MergeSelectionAndMaskIntoMask(globals);
	
	// This shows how to set up the overlay information in your proxy view.
	// We used this for the painting in Extract. You may want to play with
	// that plug in for a better use of overlays.
	if (gOverlayData == NULL)
	{
		gOverlayData = gPSBufferSuite64->New(NULL, memorySize);
		if (gOverlayData == NULL)
		{
			gResult = memFullErr;
			return;
		}
	}
	HelloWorldMaskData(gOverlayData, &outRect, &gProxyRect, true);
}
Example #2
0
/*-------------------------------------------------------------------*
 |  dxfReadTableType                                                 |
 |  Inputs:                                                          |
 |      HDXF hDxf = handle to the openning DXF file structure        |
 |      LPVOID pTableType = pointer to table type structure          |
 |  Output: TableType Code else TAB_NOTSET                           |
 *-------------------------------------------------------------------*/
DWORD dxfReadTableType( HDXF hDxf, LPVOID pTableType )
{
	PDXF	pDxf;
	int		GCode;
	char	strValue[2048];
	DWORD	result;

	// Initialize pDxf ------------------
	if((pDxf = InitilizePDXF(hDxf))==NULL)
		return FALSE;

	// Check if current section is TABLES
	if(pDxf->Read.CurrentSection!=SEC_TABLES)
	{
		// Current section is not TABLES
		GlobalUnlock(hDxf);
		return TAB_NOTSET;
	}

	// Looking for next table type if CurrentTableType==TAB_NOTSET
	if(pDxf->Read.CurrentTableType==TAB_NOTSET)
	{
		if(dxfFindNextTableType(hDxf)==TAB_NOTSET)
		{
			pDxf->Read.CurrentSection = SEC_NOTSET;
			GlobalUnlock(hDxf);
			return TAB_NOTSET;
		}
	}

	// Read current table type data
	result = TAB_NOTSET;
	switch(pDxf->Read.CurrentTableType)
	{
	case TAB_DIMSTYLE:
		if(!FindParamFromDxfFile(pDxf, 0, "DIMSTYLE"))
			break;
		else
		{
			if(ReadDimStyleData(pDxf, (PDXFDIMSTYLE)pTableType))
				result = TAB_DIMSTYLE;
		}
		break;

	case TAB_LAYER:
		if(!FindParamFromDxfFile(pDxf, 0, "LAYER"))
			break;
		else
		{
			if(ReadLayerData(pDxf, (PDXFLAYER)pTableType))
				result = TAB_LAYER;
		}
		break;

	case TAB_LTYPE:
		if(!FindParamFromDxfFile(pDxf, 0, "LTYPE"))
			break;
		else
		{
			if(ReadLTypeData(pDxf, (PDXFLTYPE)pTableType))
				result = TAB_LTYPE;
		}
		break;

	case TAB_STYLE:
		if(!dxfFindParam( hDxf, 0, "STYLE" ))
			break;
		else
		{
			if(ReadStyleData(pDxf, (PDXFSTYLE)pTableType))
				result = TAB_STYLE;
		}
		break;
	}

	dxfStorePos(pDxf);
	dxfReadParam(hDxf, GCode, strValue);

	if((GCode==0) && (strcmp(strValue, "ENDTAB")==0))
	{
		pDxf->Read.CurrentTableType = TAB_NOTSET;

//		while(dxfReadTableTypeName(hDxf)==TAB_NOTSET)
//		{
			dxfStorePos(pDxf);
			dxfReadParam(hDxf, GCode, strValue);
			if((GCode==0) && (strcmp(strValue, "ENDSEC")==0))
			{
				pDxf->Read.CurrentSection = SEC_NOTSET; // Tables section has been finished
//				break;
			}
			else
				dxfRestorePos(pDxf);
//		}
	}
	else
		dxfRestorePos(pDxf);

	// UnInitilize hDxf -----------------
	UnInitilizePDXF(hDxf);

	return result;
}
Example #3
0
void DoEffect(GPtr globals)
{
	// Get a buffer to hold each channel as we process
	char *pLayerData = gPSBufferSuite64->New(NULL, 
										   VSIZE * HSIZE * gXFactor * gXFactor);
	if (pLayerData == NULL)
		return;
		
	// Start with the first target composite channel
	ReadChannelDesc *pChannel = gDocDesc->targetCompositeChannels;

	// we may have a multichannel document
	if (pChannel == NULL)
		pChannel = gDocDesc->alphaChannels;
	
	// Get some information for the progress bar
	int32 done = 0;
	int32 total = NumberOfChannels(globals) + 1;
	
	// Loop through each of the channels
	while (pChannel != NULL && gResult == 0)
	{
		// Update the progress bar
		PIUpdateProgress(done++, total);
		
		// Read in this channel data, we actually don't need this data
	 	// but I will read it in anyway, it is an example you know
		ReadLayerData(globals, pChannel, pLayerData, false);
		
		// Stamp the "Hello World" into the data buffer
		HelloWorldData(globals, pLayerData);
		
		// Decide if we should blur our effect or just write out the
		// data. GaussianBlurEffect() will use a new channel port
		if (gGaussianBlurData)
			{
			Rect write_rect;
			write_rect.top = gPointV;
			write_rect.left = gPointH;
			write_rect.bottom = (short)(gPointV + VSIZE * gXFactor);
			write_rect.right = (short)(gPointH + HSIZE * gXFactor);
			GaussianBlurEffect(globals, &write_rect, pLayerData);
			}
		WriteLayerData(globals, pChannel, pLayerData);
			
		// off to the next channel
		pChannel = pChannel->next;
	}

	// Update the progress bar
	PIUpdateProgress(done++, total);
	
	// now update the transparency information
	// this will be non null for layered data
	pChannel = gDocDesc->targetTransparency;
	if (gResult == 0)
	{
		// Read in this channel data, we actually don't need this data
	 	// but I will read it in anyway, it is an example you know
		ReadLayerData(globals, pChannel, pLayerData, false);

		// Stamp the "Hello World" into the data buffer
		HelloWorldMaskData(globals, pLayerData);

		// write out the channel mask
		WriteLayerData(globals, pChannel, pLayerData);
	}

	// Update the progress bar
	PIUpdateProgress(done++, total);
	
	// dispose of that temp buffer we have been using
	gPSBufferSuite64->Dispose((char**)&pLayerData);
}