void CNodeSubtract::UpdateOutputs()
{
	if ( !GetNumJacks_Out() || !GetNumJacks_In() )
		return;

	if ( GetErrorLevel() != ERRORLEVEL_NONE )
		return SetOutputsUndefined();

	GetJack_Out( 0 )->SetSmartType( max( GetJack_In(0)->GetSmartType(), GetJack_In(1)->GetSmartType() ) );
}
void CNodeUtility_Assign::UpdateOutputs()
{
	if ( !GetNumJacks_Out() || !GetNumJacks_In() )
		return;

	if ( GetErrorLevel() != ERRORLEVEL_NONE )
		return SetOutputsUndefined();

	GetJack_Out( 0 )->SetSmartType( GetJack_In(0)->GetSmartType() );
}
예제 #3
0
void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                       const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
    COLOR4D color = m_Color;
    COLOR4D tmp   = color;

    if( GetMarkerType() == MARKER_BASE::MARKER_ERC )
    {
        color = ( GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR ) ?
                  GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN );
    }

    if( aColor == COLOR4D::UNSPECIFIED )
        m_Color = color;
    else
        m_Color = aColor;

    DrawMarker( aPanel, aDC, aDrawMode, aOffset );
    m_Color = tmp;
}
void CNodeMultiply::UpdateOutputs()
{
	if ( !GetNumJacks_Out() || !GetNumJacks_In() )
		return;

	if ( GetErrorLevel() != ERRORLEVEL_NONE )
		return SetOutputsUndefined();

	CJack *pJO = GetJack_Out( 0 );
	int vartype_jack_0 = GetJack_In( 0 )->GetSmartType();
	int vartype_jack_1 = GetJack_In( 1 )->GetSmartType();

	int iGoalSmarttype = HLSLVAR_FLOAT4;

	// matrices out
	if ( vartype_jack_0 == HLSLVAR_MATRIX3X3 && vartype_jack_1 == HLSLVAR_MATRIX3X3 )
		iGoalSmarttype = HLSLVAR_MATRIX3X3;
	else if ( vartype_jack_0 == HLSLVAR_MATRIX4X4 && vartype_jack_1 == HLSLVAR_MATRIX4X4 )
		iGoalSmarttype = HLSLVAR_MATRIX4X4;
	else if ( vartype_jack_0 == HLSLVAR_MATRIX4X3 && vartype_jack_1 == HLSLVAR_MATRIX4X4 )
		iGoalSmarttype = HLSLVAR_MATRIX4X4;
	// vector out
	else if ( vartype_jack_0 == HLSLVAR_FLOAT1 || vartype_jack_1 == HLSLVAR_FLOAT1 )
		iGoalSmarttype =  max( vartype_jack_0, vartype_jack_1 );
	else if ( vartype_jack_0 == vartype_jack_1 )
		iGoalSmarttype = vartype_jack_0;
	// vector transform out
	else if ( vartype_jack_1 == HLSLVAR_MATRIX3X3 ||
		vartype_jack_0 == HLSLVAR_MATRIX3X3 ||
		vartype_jack_1 == HLSLVAR_MATRIX4X3 ||
		( vartype_jack_1 == HLSLVAR_MATRIX4X4 && m_bMatrixRotation ) )
		iGoalSmarttype = HLSLVAR_FLOAT3;

	return pJO->SetSmartType( iGoalSmarttype );
	//GetJack_Out( 0 )->SetSmartType( max( GetJack_In(0)->GetSmartType(), GetJack_In(1)->GetSmartType() ) );
}
bool CBaseContainerNode::VguiDraw( bool bShadow )
{
#define TITEL_INSET_X NODE_DRAW_TITLE_SPACE
	if ( !ShouldSimpleDrawObject( pNodeView, pNodeView, m_vecBounds ) )
		return false;
	if ( !pNodeView )
		return false;

	Vector2D title_min = GetBoundsTitleMin();
	Vector2D title_max = GetBoundsTitleMax();
	title_max.x -= TITEL_INSET_X;

	Vector2D box_min = GetBoundsBoxMin();
	Vector2D box_max = GetBoundsBoxMax();

	pNodeView->ToPanelSpace( title_min );
	pNodeView->ToPanelSpace( title_max );
	pNodeView->ToPanelSpace( box_min );
	pNodeView->ToPanelSpace( box_max );

	float flZoom = pNodeView->GetZoomScalar();
	float flO = NODE_DRAW_SHADOW_DELTA * flZoom;
	Vector2D offset( flO, flO );

	if ( bShadow )
	{
		title_min += offset;
		title_max += offset;
		box_min += offset;
		box_max += offset;
	}

	const bool bSelected = IsSelected();

	if ( bShadow )
		surface()->DrawSetColor( NODE_DRAW_COLOR_SHADOW );
	else
	{
		Color colTitleNoShadow = NODE_DRAW_COLOR_TITLE;
		if ( GetNumContainers() )
			colTitleNoShadow = NODE_DRAW_COLOR_HASCONTAINER_TITLE;
		else if ( bSelected )
			colTitleNoShadow = NODE_DRAW_COLOR_SELECTED_TITLE;
		surface()->DrawSetColor( colTitleNoShadow );
	}

	surface()->DrawFilledRect( title_min.x, title_min.y, title_max.x, title_max.y );

	if ( !bShadow )
	{
		Color boxNoShadow = NODE_DRAW_COLOR_BOX;
		if ( bSelected )
			boxNoShadow = NODE_DRAW_COLOR_SELECTED_BOX;
		else if ( GetNumSolvers() && !HasDummySolvers() )
			boxNoShadow = NODE_DRAW_COLOR_HASSOLVER_BOX;

		surface()->DrawSetColor( boxNoShadow );
	}

	surface()->DrawFilledRect( box_min.x, box_min.y, box_max.x, box_max.y );

	//Vector2D r0_min = GetContainerBorderMin( CBORDER_TOP_LEFT );
	//Vector2D r0_max = GetContainerBorderMax( CBORDER_TOP_RIGHT );
	//Vector2D r1_min = GetContainerBorderMin( CBORDER_RIGHT );
	//Vector2D r1_max = GetContainerBorderMax( CBORDER_RIGHT );
	//Vector2D r2_min = GetContainerBorderMin( CBORDER_BOTTOM_LEFT );
	//Vector2D r2_max = GetContainerBorderMax( CBORDER_BOTTOM_RIGHT );
	//Vector2D r3_min = GetContainerBorderMin( CBORDER_RIGHT );
	//Vector2D r3_max = GetContainerBorderMax( CBORDER_RIGHT );
	Vector2D rects_[8] = {
	GetContainerBorderMin( CBORDER_TOP_LEFT ),
	GetContainerBorderMax( CBORDER_TOP_RIGHT ),
	GetContainerBorderMin( CBORDER_RIGHT ),
	GetContainerBorderMax( CBORDER_RIGHT ),
	GetContainerBorderMin( CBORDER_BOTTOM_LEFT ),
	GetContainerBorderMax( CBORDER_BOTTOM_RIGHT ),
	GetContainerBorderMin( CBORDER_LEFT ),
	GetContainerBorderMax( CBORDER_LEFT ),
	};
	for ( int i = 0; i < 8; i++ )
		pNodeView->ToPanelSpace( rects_[i] );

	if ( bShadow )
	{
		for ( int i = 0; i < 8; i++ )
			rects_[i] += offset;
	}

	for ( int i = 0; i < 4; i++ )
		surface()->DrawFilledRect( rects_[i*2].x, rects_[i*2+1].y, rects_[i*2+1].x, rects_[i*2].y );


	if ( bShadow )
	{
		VguiDraw_Jacks( true );
	}
	else
	{
		VguiDraw_Jacks( false );
		Color borderCol = NODE_DRAW_COLOR_BORDER;
		if ( GetErrorLevel() == ERRORLEVEL_UNDEFINED )
			borderCol = DRAWCOLOR_ERRORLEVEL_UNDEFINED;
		else if ( GetErrorLevel() == ERRORLEVEL_FAIL )
			borderCol = DRAWCOLOR_ERRORLEVEL_FAIL;
		else if ( IsAllocating() )
			borderCol = NODE_DRAW_COLOR_HASSOLVER_BOX_ALLOC;
		surface()->DrawSetColor( borderCol );

		int borderSize = 1;
		surface()->DrawFilledRect( title_min.x, title_min.y, title_max.x, title_min.y + borderSize );
		surface()->DrawFilledRect( title_min.x, title_max.y - borderSize, title_max.x, title_max.y );
		surface()->DrawFilledRect( title_min.x, title_min.y, title_min.x + borderSize, title_max.y );
		surface()->DrawFilledRect( title_max.x - borderSize, title_min.y, title_max.x, title_max.y );

		surface()->DrawFilledRect( box_min.x, box_min.y, box_max.x, box_min.y + borderSize );
		surface()->DrawFilledRect( box_min.x, box_max.y - borderSize, box_max.x, box_max.y );
		surface()->DrawFilledRect( box_min.x, box_min.y, box_min.x + borderSize, box_max.y );
		//surface()->DrawFilledRect( box_max.x - borderSize, box_min.y, box_max.x, box_max.y );

		surface()->DrawFilledRect( box_max.x, rects_[1].y, box_max.x + borderSize, box_min.y + borderSize );
		surface()->DrawFilledRect( box_max.x, box_max.y - borderSize, box_max.x + borderSize, rects_[4].y );
		surface()->DrawFilledRect( rects_[7].x-borderSize, rects_[7].y, rects_[7].x, rects_[6].y );

		surface()->DrawFilledRect( rects_[2].x, rects_[3].y, rects_[2].x+borderSize, rects_[2].y );
		surface()->DrawFilledRect( rects_[3].x-borderSize, rects_[1].y, rects_[3].x, rects_[4].y );

		surface()->DrawFilledRect( rects_[0].x, rects_[1].y, rects_[1].x, rects_[1].y+borderSize );
		surface()->DrawFilledRect( rects_[4].x, rects_[4].y-borderSize, rects_[5].x, rects_[4].y );

		surface()->DrawFilledRect( rects_[7].x-borderSize, rects_[0].y-borderSize, rects_[2].x+borderSize, rects_[0].y );
		surface()->DrawFilledRect( rects_[7].x-borderSize, rects_[5].y, rects_[2].x+borderSize, rects_[5].y+borderSize );
	}

	Vector2D titleMid = ( title_max - title_min ) * 0.5f + title_min;

	wchar_t szconverted[ 1024 ];
	int fontWide, fontTall;

	if ( !bShadow )
	{
		bool bDraw;
		vgui::HFont hFont_Small = pNodeView->GetFontScaled(12,bDraw);
		if ( bDraw )
		{
			g_pVGuiLocalize->ConvertANSIToUnicode( szOpName, szconverted, sizeof(szconverted)  );

			surface()->DrawSetTextFont( hFont_Small );
			surface()->GetTextSize( hFont_Small, szconverted, fontWide, fontTall );
			surface()->DrawSetTextPos( titleMid.x - fontWide * 0.5f, titleMid.y - fontTall * 0.5f );

			surface()->DrawSetTextColor( bSelected ? NODE_DRAW_COLOR_SELECTED_TEXT_OP : NODE_DRAW_COLOR_TEXT_OP );
			surface()->DrawPrintText( szconverted, wcslen( szconverted ) );
		}

		//VguiDraw_Preview();
		DrawGrabIcon();
	}


	if ( Q_strlen( szNodeName ) > 1 )
	{
		surface()->DrawSetTextColor( bShadow ? NODE_DRAW_COLOR_SHADOW : NODE_DRAW_COLOR_CUSTOMTITLE );

		bool bDraw;
		vgui::HFont hFont_Small = pNodeView->GetFontScaled(18,bDraw);
		if ( bDraw )
		{
			g_pVGuiLocalize->ConvertANSIToUnicode( szNodeName, szconverted, sizeof(szconverted) );

			surface()->DrawSetTextFont( hFont_Small );
			surface()->GetTextSize( hFont_Small, szconverted, fontWide, fontTall );
			surface()->DrawSetTextPos( title_min.x, title_min.y - fontTall - 3 * pNodeView->GetZoomScalar() );

			surface()->DrawPrintText( szconverted, wcslen( szconverted ) );
		}
	}

	return true;
}