PF_Err
Arb_Print(
	PF_InData			*in_data,
	PF_OutData			*out_data,
	PF_ArbPrintFlags	print_flags,
	PF_ArbitraryH		arbH,
	A_u_long			print_sizeLu,
	A_char				*print_bufferPC)
{
	PF_Err		err			= PF_Err_NONE;
	PF_Handle	a_handle	= arbH;
	A_long 		countL 		= 0;
	if (a_handle) {
		CG_ArbData	*a_arbP;
				
		a_arbP = (CG_ArbData*)PF_LOCK_HANDLE(a_handle);

		if (!a_arbP) {
			err = PF_Err_UNRECOGNIZED_PARAM_TYPE;
		} else {	
			if (!print_flags && print_sizeLu >= COLORGRID_ARB_MAX_PRINT_SIZE) {
				A_u_long		indexLu = 0;
				A_char			bufAC[64];

				// All data for this one parameter must be on the same line
				for (countL = 0; countL < CG_ARBDATA_ELEMENTS; ++countL) {
					PF_SPRINTF(bufAC, "ColorGrid %d\t", countL + 1);

					ERR(AEFX_AppendText(bufAC, (const A_u_long)print_sizeLu, print_bufferPC, &indexLu));	

					if (!err) {
						PF_SPRINTF(	bufAC, 
									"R=%f\tG=%f\tB=%f\t",
									a_arbP->colorA[countL].red,
									a_arbP->colorA[countL].green,
									a_arbP->colorA[countL].blue);

						ERR(AEFX_AppendText(bufAC, (const A_u_long)print_sizeLu, print_bufferPC, &indexLu));	
					}
				}
			} else if ((print_sizeLu) && print_bufferPC) {
				print_bufferPC[0] = 0x00;
			}
			PF_UNLOCK_HANDLE(a_handle);
		}
	}
	if (err == AEFX_ParseError_APPEND_ERROR) {
		err = PF_Err_OUT_OF_MEMORY; // increase COLORGRID_ARB_MAX_PRINT_SIZE
	}
	return err;
}
PF_Err	
CreateDefaultArb(	
	PF_InData			*in_data,
	PF_OutData			*out_data,
	PF_ArbitraryH		*dephault)
{
	PF_Err			err		= PF_Err_NONE;
	PF_Handle		arbH	= NULL;
	
	AEGP_SuiteHandler	suites(in_data->pica_basicP);
	
	arbH = suites.HandleSuite1()->host_new_handle(sizeof(CG_ArbData));

	if (arbH) {
		CG_ArbData	*arbP = reinterpret_cast<CG_ArbData*>(PF_LOCK_HANDLE(arbH));
		if (!arbP) {
			err = PF_Err_OUT_OF_MEMORY;
		} else {
			AEFX_CLR_STRUCT(*arbP);
			#ifdef AE_OS_WIN
				#pragma warning (disable : 4305)
			#endif
			arbP->colorA[0].alpha	= 1.0;
			arbP->colorA[0].blue	= 0.0;
			arbP->colorA[0].green	= 0.5;
			arbP->colorA[0].red		= 1.0;
			
			arbP->colorA[1].alpha	= 1.0;
			arbP->colorA[1].blue	= 0.5;
			arbP->colorA[1].green	= 0.32;
			arbP->colorA[1].red		= 0.67;
			
			arbP->colorA[2].alpha	= 1.0;
			arbP->colorA[2].blue	= 0.6;
			arbP->colorA[2].green	= 0.27;
			arbP->colorA[2].red		= 0.34;
			
			arbP->colorA[3].alpha	= 1.0;
			arbP->colorA[3].blue	= 1.0;
			arbP->colorA[3].green	= 0.4039;
			arbP->colorA[3].red		= 0.47;
			
			arbP->colorA[4].alpha	= 1.0;
			arbP->colorA[4].blue	= 0.47;
			arbP->colorA[4].green	= 0.54;
			arbP->colorA[4].red		= 0.603;
			
			arbP->colorA[5].alpha	= 1.0;
			arbP->colorA[5].blue	= 0.0603;
			arbP->colorA[5].green	= 0.67;
			arbP->colorA[5].red		= 0.9;
			
			arbP->colorA[6].alpha	= 1.0;
			arbP->colorA[6].blue	= 0.737;
			arbP->colorA[6].green	= 0.81;
			arbP->colorA[6].red		= 0.89;
			
			arbP->colorA[7].alpha	= 1.0;
			arbP->colorA[7].blue	= 0.5;
			arbP->colorA[7].green	= 1.0;
			arbP->colorA[7].red		= 0.5;
			
			arbP->colorA[8].alpha	= 1.0;
			arbP->colorA[8].blue	= 0.5;
			arbP->colorA[8].green	= 0.5;
			arbP->colorA[8].red		= 0.9;
			#ifdef AE_OS_WIN
				#pragma warning (pop)
			#endif
			*dephault = arbH;
		}
		suites.HandleSuite1()->host_unlock_handle(arbH);
	}
	return err;
}
PF_Err
Arb_Compare(
	PF_InData				*in_data,
	PF_OutData				*out_data,
	const PF_ArbitraryH		*a_arbP,
	const PF_ArbitraryH		*b_arbP,
	PF_ArbCompareResult		*resultP)
{
	PF_Err err = PF_Err_NONE;
	
	PF_Handle	a_handle = *a_arbP,
				b_handle = *b_arbP;

	PF_FpShort		total_a_rL	= 0,
					total_a_gL	= 0,
					total_a_bL	= 0,
					total_aL	= 0,
				
					total_b_rL	= 0,
					total_b_gL	= 0,
					total_b_bL	= 0,
					total_bL	= 0;

	*resultP = PF_ArbCompare_EQUAL;

	if (a_handle && b_handle) {
		CG_ArbData	*first_arbP;
		CG_ArbData  *second_arbP;
				
		first_arbP = (CG_ArbData*)PF_LOCK_HANDLE(a_handle);
		second_arbP = (CG_ArbData*)PF_LOCK_HANDLE(b_handle);

		if (!first_arbP || !second_arbP) {
			err = PF_Err_UNRECOGNIZED_PARAM_TYPE;
		} else {	
			A_long iL = 0;
			
			while (iL++ < CG_ARBDATA_ELEMENTS){	
				total_a_rL	+= first_arbP->colorA->red;
				total_a_gL	+= first_arbP->colorA->green;
				total_a_bL	+= first_arbP->colorA->blue;

				total_b_rL	+= second_arbP->colorA->red;
				total_b_gL	+= second_arbP->colorA->green;
				total_b_bL	+= second_arbP->colorA->blue;
				
				first_arbP++;
				second_arbP++;
			}

			total_aL = total_a_rL + total_a_gL + total_a_bL;
			total_bL = total_b_rL + total_b_gL + total_b_bL; 

			if(total_aL > total_bL)	{
				*resultP = PF_ArbCompare_MORE;
			} else if(total_aL < total_bL){
				*resultP = PF_ArbCompare_LESS;
			} else {
				*resultP = PF_ArbCompare_EQUAL;
			}
			PF_UNLOCK_HANDLE(a_handle);
			PF_UNLOCK_HANDLE(b_handle);
		}
	}
	return err;
}
Beispiel #4
0
static PF_Err
DrawEvent(	
	PF_InData		*in_data,
	PF_OutData		*out_data,
	PF_ParamDef		*params[],
	PF_LayerDef		*output,
	PF_EventExtra	*event_extra)
{
	PF_Err			err		=	PF_Err_NONE;
	
	AEGP_SuiteHandler suites(in_data->pica_basicP);
	

	event_extra->evt_out_flags = 0;
	

	if (!(event_extra->evt_in_flags & PF_EI_DONT_DRAW) && params[EXTRACT_DATA]->u.arb_d.value != NULL)
	{
		if(PF_EA_CONTROL == event_extra->effect_win.area)
		{
			ArbitraryData *arb_data = (ArbitraryData *)PF_LOCK_HANDLE(params[EXTRACT_DATA]->u.arb_d.value);
			ExtractStatus *extract_status = (ExtractStatus *)PF_LOCK_HANDLE(in_data->sequence_data);
		
		#define MAX_MESSAGE_LEN 127
			A_char	red_message[MAX_MESSAGE_LEN],
					green_message[MAX_MESSAGE_LEN],
					blue_message[MAX_MESSAGE_LEN],
					alpha_message[MAX_MESSAGE_LEN];
					
			A_char	*channel_message[4] = {	red_message,
											green_message,
											blue_message,
											alpha_message };
			
			ChannelStatus *channel_status[4] = {	&extract_status->red,
													&extract_status->green,
													&extract_status->blue,
													&extract_status->alpha };
												
			ChannelData *channel_data[4] = {	&arb_data->red,
												&arb_data->green,
												&arb_data->blue,
												&arb_data->alpha };
		
			// set up the messages
			for(int i=0; i<4; i++)
			{
				if(channel_data[i]->action == DO_COPY)
				{
					strcpy(channel_message[i], "(copy)");
				}
				else if(channel_data[i]->action == DO_EXTRACT)
				{
					// start with the name
					strcpy(channel_message[i], channel_data[i]->name);
					
					// process status returned from Render()
					if(channel_status[i]->status == STATUS_NOT_FOUND)
					{
						strcat(channel_message[i], " (not found)");
					}
					else if(channel_status[i]->status == STATUS_NO_CHANNELS)
					{
						strcat(channel_message[i], " (none available)");
					}
					else if(channel_status[i]->status == STATUS_ERROR)
					{
						strcat(channel_message[i], " (error)");
					}
					// can't change params during draw, need a click
					//else if(channel_status[i]->status == STATUS_INDEX_CHANGE)
					//{
					//	channel_data[i]->index = channel_status[i]->index;
					//	params[EXTRACT_DATA]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
					//}
				}
			}
			
			PF_Rect control_rect = event_extra->effect_win.current_frame;
			
			
#if PF_AE_PLUG_IN_VERSION < PF_AE100_PLUG_IN_VERSION

		// old-school Carbon/Win32 drawing code

		#ifdef WIN_ENV
			void*			dp = (*(event_extra->contextH))->cgrafptr;
			HDC				ecw_hdc	=	0;
			PF_GET_CGRAF_DATA(dp, PF_CGrafData_HDC, (void **)&ecw_hdc);
			PF_Point		pen;
		#endif

			PF_App_Color	pf_bg_color;
			suites.AppSuite()->PF_AppGetBgColor(&pf_bg_color);
			
		#ifdef MAC_ENV
			RGBColor titleColor, itemColor;
			RGBColor		bg_color;
	
			bg_color.red	=	pf_bg_color.red;
			bg_color.green	=	pf_bg_color.green;
			bg_color.blue	=	pf_bg_color.blue;
			
			RGBBackColor(&bg_color);
		
			EraseRect(&control_rect);
			
			GetForeColor(&itemColor);
			
			titleColor.red   = TITLE_COMP(itemColor.red);
			titleColor.green = TITLE_COMP(itemColor.green);
			titleColor.blue  = TITLE_COMP(itemColor.blue);
				
			RGBForeColor(&titleColor);
		#endif

		#ifdef MAC_ENV
		#define DRAW_STRING(STRING)	DrawText(STRING, 0, strlen(STRING));
		#define MOVE_TO(H, V)		MoveTo( (H), (V) );
		#else
		#define DRAW_STRING(STRING) \
			do{ \
				WCHAR u_string[100]; \
				UTF8toUTF16(STRING, (utf16_char *)u_string, 99); \
				TextOut(ecw_hdc, pen.h, pen.v, u_string, strlen(STRING)); \
			}while(0);
		#define MOVE_TO(H, V)		MoveToEx(ecw_hdc, (H), (V), NULL); pen.h = (H); pen.v = (V);
		#endif

		
#else // PF_AE_PLUG_IN_VERSION >= PF_AE100_PLUG_IN_VERSION

			// new-school Drawbot drawing code
			
			DRAWBOT_DrawRef			drawbot_ref = NULL;
			suites.PFEffectCustomUISuite()->PF_GetDrawingReference(event_extra->contextH, &drawbot_ref);
			
			DRAWBOT_SupplierRef		supplier_ref = NULL;
			DRAWBOT_SurfaceRef		surface_ref = NULL;

			suites.DBDrawbotSuite()->GetSupplier(drawbot_ref, &supplier_ref);
			suites.DBDrawbotSuite()->GetSurface(drawbot_ref, &surface_ref);
				
			DRAWBOT_ColorRGBA title_color = {0.8f, 0.8f, 0.8f, 1.0f};
			DRAWBOT_ColorRGBA item_color = title_color;
			
			item_color.red *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			item_color.green *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			item_color.blue *= (1.0 - kUI_TITLE_COLOR_SCALEDOWN);
			
			DRAWBOT_BrushP title_brushP(suites.DBSupplierSuite(), supplier_ref, &title_color);
			DRAWBOT_BrushP item_brushP(suites.DBSupplierSuite(), supplier_ref, &item_color);
			
			float default_font_sizeF = 0.0;
			suites.DBSupplierSuite()->GetDefaultFontSize(supplier_ref, &default_font_sizeF);
			
			DRAWBOT_FontP fontP(suites.DBSupplierSuite(), supplier_ref, default_font_sizeF);
			
			DRAWBOT_PointF32 text_origin = {0.f, 0.f};
			
			DRAWBOT_BrushP *current_brush = &title_brushP;
			
		#define MOVE_TO(H, V) \
			text_origin.x = (H) + 0.5f; \
			text_origin.y = (V) + 0.5f;
		
		#define DRAW_STRING(STRING) \
			do{ \
				DRAWBOT_UTF16Char u_str[100]; \
				UTF8toUTF16(STRING, u_str, 99); \
				suites.DBSurfaceSuite()->DrawString(surface_ref, current_brush->Get(), fontP.Get(), u_str, \
						&text_origin, kDRAWBOT_TextAlignment_Default, kDRAWBOT_TextTruncation_None, 0.0f); \
			}while(0);
			
#endif //PF_AE_PLUG_IN_VERSION >= PF_AE100_PLUG_IN_VERSION


			// Property Headings
			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_RED, control_rect.top) );
			DRAW_STRING("Red");
			
			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_GREEN, control_rect.top) );
			DRAW_STRING("Green");

			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_BLUE, control_rect.top) );
			DRAW_STRING("Blue");

			MOVE_TO(RIGHT_STATUS(control_rect.left), DOWN_PLACE(INFO_ALPHA, control_rect.top) );
			DRAW_STRING("Alpha");
			
			//Property Items
			PF_Point prop_origin;
			prop_origin.v = control_rect.top;
			
	#if PF_AE_PLUG_IN_VERSION < PF_AE100_PLUG_IN_VERSION
		#ifdef MAC_ENV
			RGBForeColor(&itemColor);
			prop_origin.h = control_rect.left + TextWidth("Alpha", 0, strlen("Alpha"));
		#else
			SIZE text_dim = {15, 8};
			GetTextExtentPoint(ecw_hdc, TEXT("Alpha"), strlen("Alpha"), &text_dim);
			prop_origin.h = control_rect.left + text_dim.cx;
		#endif
	#else
			current_brush = &item_brushP;
			prop_origin.h = control_rect.left + 50;
	#endif
			
			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_RED, prop_origin.v) );
			DRAW_STRING(red_message);
			
			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_GREEN, prop_origin.v) );
			DRAW_STRING(green_message);

			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_BLUE, prop_origin.v) );
			DRAW_STRING(blue_message);

			MOVE_TO(RIGHT_PROP(prop_origin.h), DOWN_PLACE(INFO_ALPHA, prop_origin.v) );
			DRAW_STRING(alpha_message);
			

			event_extra->evt_out_flags = PF_EO_HANDLED_EVENT;

			PF_UNLOCK_HANDLE(params[EXTRACT_DATA]->u.arb_d.value);
			PF_UNLOCK_HANDLE(in_data->sequence_data);
		}
	}

	return err;
}
static PF_Err DrawEvent(  
    PF_InData       *in_data,
    PF_OutData      *out_data,
    PF_ParamDef     *params[],
    PF_LayerDef     *output,
    PF_EventExtra   *event_extra)
{
    PF_Err          err     =   PF_Err_NONE;
    

    if(!(event_extra->evt_in_flags & PF_EI_DONT_DRAW) &&
        params[OCIO_DATA]->u.arb_d.value != NULL)
    {
        if(event_extra->effect_win.area == PF_EA_CONTROL)
        {
            ArbitraryData *arb_data = (ArbitraryData *)PF_LOCK_HANDLE(params[OCIO_DATA]->u.arb_d.value);
            SequenceData *seq_data = (SequenceData *)PF_LOCK_HANDLE(in_data->sequence_data);
        
            DrawbotBot bot(in_data->pica_basicP, event_extra->contextH, in_data->appl_id);
            
            
            int panel_left = event_extra->effect_win.current_frame.left;
            int panel_top = event_extra->effect_win.current_frame.top;
            int panel_width = event_extra->effect_win.current_frame.right;
            int panel_height = event_extra->effect_win.current_frame.bottom;
            float text_height = bot.FontSize();
            
            if(in_data->appl_id != 'FXTC')
            {
                // for Premiere we need to paint the background first
                bot.SetColor(PF_App_Color_PANEL_BACKGROUND);
                bot.MoveTo(panel_left, panel_top);
                bot.PaintRect(panel_width, panel_height);
            }
            
            
            // configuration menu
            bot.MoveTo(panel_left + MENUS_INDENT_H, panel_top + TOP_MARGIN);
            
            std::string config_menu_text = arb_data->path;
            
            if(arb_data->source == OCIO_SOURCE_NONE)
            {
                config_menu_text = "(none)";
            }
            if(arb_data->source == OCIO_SOURCE_ENVIRONMENT)
            {
                config_menu_text = "$OCIO";
            }
            else if(arb_data->source == OCIO_SOURCE_CUSTOM)
            {
                config_menu_text = (arb_data->action == OCIO_ACTION_LUT ? "LUT" : "Custom");
            }
            
            DrawMenu(bot, "Configuration:", config_menu_text.c_str());
            
            
            if(arb_data->source == OCIO_SOURCE_CUSTOM ||
                arb_data->source == OCIO_SOURCE_ENVIRONMENT)
            {
                // path text field
                int field_left = panel_left + MENUS_INDENT_H + MENU_LABEL_WIDTH +
                                    MENU_LABEL_SPACE + MENU_WIDTH + FIELD_TEXT_INDENT_H;
                
                bot.MoveTo(field_left, panel_top + TOP_MARGIN);
                
                int field_width = MAX(panel_width - field_left + panel_left - RIGHT_MARGIN, 60);
                
                bot.SetColor(PF_App_Color_SHADOW);
                bot.PaintRect(field_width, FIELD_HEIGHT);
                bot.SetColor(PF_App_Color_BLACK);
                bot.DrawRect(field_width, FIELD_HEIGHT);

                bot.Move(FIELD_TEXT_INDENT_H, FIELD_TEXT_INDENT_V + text_height);
                
                bot.SetColor(TEXT_COLOR);
                
                std::string file_string = "(none)";
                
                if(arb_data->source == OCIO_SOURCE_ENVIRONMENT)
                {
                    char *file = std::getenv("OCIO");
                    
                    if(file)
                        file_string = file;
                }
                else
                {
                    file_string = (seq_data->status == STATUS_USING_RELATIVE ?
                                        arb_data->relative_path : arb_data->path);
                }
                
                                    
                bot.DrawString(file_string.c_str(),
                                kDRAWBOT_TextAlignment_Default,
                                kDRAWBOT_TextTruncation_PathEllipsis,
                                field_width - (2 * FIELD_TEXT_INDENT_H));
            }
            
            
            if(seq_data->status == STATUS_FILE_MISSING)
            {
                bot.MoveTo(panel_left + MENU_LABEL_WIDTH + MENU_LABEL_SPACE,
                            panel_top + MENU_HEIGHT + BUTTONS_GAP_V + BUTTON_HEIGHT + BUTTONS_GAP_V);
                
                bot.SetColor(PF_App_Color_RED);
                bot.PaintRect(200, 50);
                
                bot.Move(100, 25 + (bot.FontSize() / 2));
                bot.SetColor(PF_App_Color_WHITE);
                
                if(arb_data->source == OCIO_SOURCE_ENVIRONMENT)
                    bot.DrawString("$OCIO NOT SET", kDRAWBOT_TextAlignment_Center);
                else
                    bot.DrawString("FILE MISSING", kDRAWBOT_TextAlignment_Center);
            }
            else
            {
                // buttons
                int field_bottom = panel_top + TOP_MARGIN + FIELD_HEIGHT;
                int buttons_top = field_bottom + BUTTONS_GAP_V;
                
                // GPU alert
                if(seq_data->gpu_err != GPU_ERR_NONE)
                {
                    bot.MoveTo(panel_left + MENU_LABEL_WIDTH + MENU_LABEL_SPACE,
                                field_bottom + bot.FontSize() + BUTTON_TEXT_INDENT_V);
                    
                    if(seq_data->gpu_err == GPU_ERR_INSUFFICIENT)
                    {
                        bot.DrawString("GPU Insufficient");
                    }
                    else if(seq_data->gpu_err == GPU_ERR_RENDER_ERR)
                    {
                        bot.DrawString("GPU Render Error");
                    }
                }
                
            #ifndef NDEBUG
                // Premiere color space (only for debugging purposes)
                if(in_data->appl_id == 'PrMr' && seq_data->prem_status != PREMIERE_UNKNOWN)
                {
                    bot.MoveTo(panel_left + MENU_LABEL_WIDTH + MENU_LABEL_SPACE + 200,
                                field_bottom + bot.FontSize() + BUTTON_TEXT_INDENT_V);
                    
                    bot.SetColor(PF_App_Color_WHITE);
                    
                    if(seq_data->prem_status == PREMIERE_LINEAR)
                    {
                        bot.DrawString("Linear Float");
                    }
                    else if(seq_data->prem_status == PREMIERE_NON_LINEAR)
                    {
                        bot.DrawString("Non-Linear Float");
                    }
                }
            #endif
                
                // Export button
                if(arb_data->action != OCIO_ACTION_NONE)
                {
                    bot.MoveTo(panel_left + BUTTONS_INDENT_H + (2 * (BUTTON_WIDTH + BUTTONS_GAP_H)), buttons_top);
                    
                    DrawButton(bot, "Export...", BUTTON_WIDTH, false);
                }
                
                if(arb_data->action == OCIO_ACTION_LUT)
                {
                    // Invert button
                    bot.MoveTo(panel_left + BUTTONS_INDENT_H, buttons_top);
                    
                    DrawButton(bot, "Invert", BUTTON_WIDTH, arb_data->invert);
                    
                    // interpolation menu
                    int buttons_bottom = buttons_top + BUTTON_HEIGHT;
                    
                    bot.MoveTo(panel_left + MENUS_INDENT_H, buttons_bottom + MENUS_GAP_V);
                    
                    const char *txt =   arb_data->interpolation == OCIO_INTERP_NEAREST ? "Nearest Neighbor" :
                                        arb_data->interpolation == OCIO_INTERP_LINEAR ? "Linear" :
                                        arb_data->interpolation == OCIO_INTERP_TETRAHEDRAL ? "Tetrahedral" :
                                        arb_data->interpolation == OCIO_INTERP_BEST ? "Best" :
                                        "Unknown";
                    
                    DrawMenu(bot, "Interpolation:", txt);
                }
                else if(arb_data->action == OCIO_ACTION_CONVERT ||
                        arb_data->action == OCIO_ACTION_DISPLAY)
                {
                    // Convert/Display buttons
                    bot.MoveTo(panel_left + BUTTONS_INDENT_H, buttons_top);
                    
                    DrawButton(bot, "Convert", BUTTON_WIDTH,
                                arb_data->action == OCIO_ACTION_CONVERT);
                    
                    bot.Move(BUTTON_WIDTH + BUTTONS_GAP_H);
                    
                    DrawButton(bot, "Display", BUTTON_WIDTH,
                                arb_data->action == OCIO_ACTION_DISPLAY);
                    
                    
                    // menus
                    int buttons_bottom = buttons_top + BUTTON_HEIGHT;
                    
                    bot.MoveTo(panel_left + MENUS_INDENT_H, buttons_bottom + MENUS_GAP_V);
                    
                    if(arb_data->action == OCIO_ACTION_CONVERT)
                    {
                        DrawMenu(bot, "Input Space:", arb_data->input);
                        
                        bot.Move(0, MENU_HEIGHT + MENU_SPACE_V);
                        
                        DrawMenu(bot, "Output Space:", arb_data->output);
                    }
                    else if(arb_data->action == OCIO_ACTION_DISPLAY)
                    {
                        // color space transformations
                        DrawMenu(bot, "Input Space:", arb_data->input);
                        
                        bot.Move(0, MENU_HEIGHT + MENU_SPACE_V);
                        
                        DrawMenu(bot, "Device:", arb_data->device);
                        
                        bot.Move(0, MENU_HEIGHT + MENU_SPACE_V);
                        
                        DrawMenu(bot, "Transform:", arb_data->transform);
                    }
                }
            }
            
            
            event_extra->evt_out_flags = PF_EO_HANDLED_EVENT;

            PF_UNLOCK_HANDLE(params[OCIO_DATA]->u.arb_d.value);
            PF_UNLOCK_HANDLE(in_data->sequence_data);
        }
    }

    return err;
}
static PF_Err DoClick( 
    PF_InData       *in_data,
    PF_OutData      *out_data,
    PF_ParamDef     *params[],
    PF_LayerDef     *output,
    PF_EventExtra   *event_extra )
{
    PF_Err          err     =   PF_Err_NONE;
    
    ArbitraryData *arb_data = (ArbitraryData *)PF_LOCK_HANDLE(params[OCIO_DATA]->u.arb_d.value);
    SequenceData *seq_data = (SequenceData *)PF_LOCK_HANDLE(in_data->sequence_data);
    
    
    if(event_extra->effect_win.area == PF_EA_CONTROL)
    {
        bool menus_visible = (arb_data->action != OCIO_ACTION_NONE);
        bool third_menu = (arb_data->action == OCIO_ACTION_DISPLAY);
        
        PF_Point local_point;
        
        local_point.h = event_extra->u.do_click.screen_point.h - event_extra->effect_win.current_frame.left;
        local_point.v = event_extra->u.do_click.screen_point.v - event_extra->effect_win.current_frame.top;
        
        UIRegion reg = WhichRegion(local_point, menus_visible, third_menu);
        
        if(reg != REGION_NONE)
        {
            try
            {
                if(reg == REGION_CONFIG_MENU)
                {
                    DoClickConfig(in_data, out_data, params, output,
                                    event_extra, arb_data, seq_data);
                }
                else if(reg == REGION_PATH)
                {
                    if(arb_data->source == OCIO_SOURCE_CUSTOM)
                    {
                        DoClickPath(in_data, out_data, params, output,
                                        event_extra, arb_data, seq_data);
                    }
                }
                else if(arb_data->action != OCIO_ACTION_NONE &&
                        seq_data->status != STATUS_FILE_MISSING)
                {
                    if(seq_data->context == NULL)
                    {
                        seq_data->context = new OpenColorIO_AE_Context(arb_data,
                                                                GetProjectDir(in_data) );
                    }
                        
                    if(reg == REGION_CONVERT_BUTTON || reg == REGION_DISPLAY_BUTTON)
                    {
                        DoClickConvertDisplay(in_data, out_data, params, output,
                                                event_extra, arb_data, seq_data, reg);
                    }
                    else if(reg == REGION_EXPORT_BUTTON)
                    {
                        DoClickExport(in_data, out_data, params, output,
                                        event_extra, arb_data, seq_data, reg);
                    }
                    else // must be a menu then
                    {
                        DoClickMenus(in_data, out_data, params, output,
                                        event_extra, arb_data, seq_data, reg);
                    }
                }
            }
            catch(std::exception &e)
            {
                if(in_data->appl_id == 'FXTC')
                {
                    PF_SPRINTF(out_data->return_msg, e.what());
                    
                    out_data->out_flags |= PF_OutFlag_DISPLAY_ERROR_MESSAGE;
                }
                else
                {
                    void *hwndOwner = NULL;

                #ifdef WIN_ENV
                    PF_GET_PLATFORM_DATA(PF_PlatData_MAIN_WND, &hwndOwner);
                #endif

                    ErrorMessage(e.what(), hwndOwner);
                }
            }
            catch(...)
            {
                PF_SPRINTF(out_data->return_msg, "Unknown error");
                
                out_data->out_flags |= PF_OutFlag_DISPLAY_ERROR_MESSAGE;
            }
        }
    }
    
    
    PF_UNLOCK_HANDLE(params[OCIO_DATA]->u.arb_d.value);
    PF_UNLOCK_HANDLE(in_data->sequence_data);
    
    event_extra->evt_out_flags = PF_EO_HANDLED_EVENT;
    
    return err;
}
Beispiel #7
0
static PF_Err 
HandleArbitrary(
	PF_InData			*in_data,
	PF_OutData			*out_data,
	PF_ParamDef			*params[],
	PF_LayerDef			*output,
	PF_ArbParamsExtra	*extra)
{
	PF_Err 	err 	= PF_Err_NONE;
	void 	*srcP	= NULL,
		 	*dstP	= NULL;

	switch (extra->which_function) {
	
	case PF_Arbitrary_NEW_FUNC:
		if (extra->u.new_func_params.refconPV != ARB_REFCON) {
			err = PF_Err_INTERNAL_STRUCT_DAMAGED;
		} else {
			err = CreateDefaultArb(	in_data,
									out_data,
									extra->u.new_func_params.arbPH);
		}
		break;

	case PF_Arbitrary_DISPOSE_FUNC:
		if (extra->u.dispose_func_params.refconPV != ARB_REFCON) {
			err = PF_Err_INTERNAL_STRUCT_DAMAGED;
		} else {
			PF_DISPOSE_HANDLE(extra->u.dispose_func_params.arbH);
		}
		break;

	case PF_Arbitrary_COPY_FUNC:
		if(extra->u.copy_func_params.refconPV == ARB_REFCON) {
			ERR(CreateDefaultArb(	in_data,
									out_data,
									extra->u.copy_func_params.dst_arbPH));

			ERR(Arb_Copy(	in_data,
							out_data,
							&extra->u.copy_func_params.src_arbH,
							extra->u.copy_func_params.dst_arbPH));
		}
		break;
	case PF_Arbitrary_FLAT_SIZE_FUNC:
		*(extra->u.flat_size_func_params.flat_data_sizePLu) = sizeof(CG_ArbData);
		break;

	case PF_Arbitrary_FLATTEN_FUNC:

		if(extra->u.flatten_func_params.buf_sizeLu == sizeof(CG_ArbData)){
			srcP = (CG_ArbData*)PF_LOCK_HANDLE(extra->u.flatten_func_params.arbH);
			dstP = extra->u.flatten_func_params.flat_dataPV;
			if (srcP){
				memcpy(dstP,srcP,sizeof(CG_ArbData));
			}
			PF_UNLOCK_HANDLE(extra->u.flatten_func_params.arbH);
		}
		break;

	case PF_Arbitrary_UNFLATTEN_FUNC:
		if(extra->u.unflatten_func_params.buf_sizeLu == sizeof(CG_ArbData)){		
			PF_Handle	handle = PF_NEW_HANDLE(sizeof(CG_ArbData));
			dstP = (CG_ArbData*)PF_LOCK_HANDLE(handle);
			srcP = (void*)extra->u.unflatten_func_params.flat_dataPV;
			if (srcP){
				memcpy(dstP,srcP,sizeof(CG_ArbData));
			}
			*(extra->u.unflatten_func_params.arbPH) = handle;
			PF_UNLOCK_HANDLE(handle);
		}
		break;

	case PF_Arbitrary_INTERP_FUNC:
		if(extra->u.interp_func_params.refconPV == ARB_REFCON) {
			ERR(CreateDefaultArb(	in_data,
									out_data,
									extra->u.interp_func_params.interpPH));
			
			ERR(Arb_Interpolate(	in_data,
									out_data,
									extra->u.interp_func_params.tF,
									&extra->u.interp_func_params.left_arbH,
									&extra->u.interp_func_params.right_arbH,
									extra->u.interp_func_params.interpPH));
		}
		break;

	case PF_Arbitrary_COMPARE_FUNC:
		ERR(Arb_Compare(	in_data,
							out_data,
							&extra->u.compare_func_params.a_arbH,
							&extra->u.compare_func_params.b_arbH,
							extra->u.compare_func_params.compareP));
		break;

	case PF_Arbitrary_PRINT_SIZE_FUNC:
		if (extra->u.print_size_func_params.refconPV == ARB_REFCON) {
			*extra->u.print_size_func_params.print_sizePLu = COLORGRID_ARB_MAX_PRINT_SIZE;		
		} else {
			err = PF_Err_UNRECOGNIZED_PARAM_TYPE;
		}
		break;

	case PF_Arbitrary_PRINT_FUNC:

		if (extra->u.print_func_params.refconPV == ARB_REFCON) {
			ERR(Arb_Print(in_data,
							out_data,
							extra->u.print_func_params.print_flags,
							extra->u.print_func_params.arbH,
							extra->u.print_func_params.print_sizeLu,
							extra->u.print_func_params.print_bufferPC));
		} else {
			err = PF_Err_UNRECOGNIZED_PARAM_TYPE;
		}
		break;

	case PF_Arbitrary_SCAN_FUNC:
		if (extra->u.scan_func_params.refconPV == ARB_REFCON) {
			ERR(Arb_Scan(	in_data,
							out_data,
							extra->u.scan_func_params.refconPV,
							extra->u.scan_func_params.bufPC,
							extra->u.scan_func_params.bytes_to_scanLu,
							extra->u.scan_func_params.arbPH));					
		} else {
			err = PF_Err_UNRECOGNIZED_PARAM_TYPE;
		}
		break;
	}
	return err;
}