Exemple #1
0
void wxSFLineShape::OnEndHandle(wxSFShapeHandle& handle)
{
	// update percentual offset of the line's ending points

    wxSFShapeBase *pParent = GetParentCanvas()->GetShapeUnderCursor();

    if( pParent )
    {
        wxRect bbRect = pParent->GetBoundingBox();

        switch( handle.GetType() )
        {
            case wxSFShapeHandle::hndLINESTART:
                if( !m_fStandAlone && ( pParent->GetId() == m_nSrcShapeId ) )
                {
                    m_nSrcOffset.x = double(handle.GetPosition().x - bbRect.GetLeft()) / bbRect.GetWidth();
                    m_nSrcOffset.y = double(handle.GetPosition().y - bbRect.GetTop()) / bbRect.GetHeight();
                }
                break;

            case wxSFShapeHandle::hndLINEEND:
                if( !m_fStandAlone && ( pParent->GetId() == m_nTrgShapeId ) )
                {
                    m_nTrgOffset.x = double(handle.GetPosition().x - bbRect.GetLeft()) / bbRect.GetWidth();
                    m_nTrgOffset.y = double(handle.GetPosition().y - bbRect.GetTop()) / bbRect.GetHeight();
                }
                break;

            default:
                break;
        }
    }
	
	wxSFShapeBase::OnEndHandle(handle);
}
Exemple #2
0
void wxSFMultiSelRect::OnTopHandle(wxSFShapeHandle& handle)
{
	if(GetParentCanvas()  && !AnyHeightExceeded(wxPoint(0, -handle.GetDelta().y)))
	{
	    wxXS::RealPointList::compatibility_iterator ptnode;
	    wxSFLineShape* pLine;
	    wxRealPoint* pt;

		double dy, sy = (GetRectSize().y - 2*sfDEFAULT_ME_OFFSET - handle.GetDelta().y)/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET);

		ShapeList m_lstSelection;
		GetParentCanvas()->GetSelectedShapes(m_lstSelection);

		ShapeList::compatibility_iterator node = m_lstSelection.GetFirst();
		while(node)
		{
			wxSFShapeBase* pShape = node->GetData();

            if(!pShape->IsKindOf(CLASSINFO(wxSFLineShape)))
            {
                if(pShape->ContainsStyle(sfsPOSITION_CHANGE))
                {
                    if(pShape->GetParentShape())
                    {
                        pShape->SetRelativePosition(pShape->GetRelativePosition().x, pShape->GetRelativePosition().y*sy);
                    }
                    else
                    {
                        double dy = handle.GetDelta().y - (pShape->GetAbsolutePosition().y - (GetAbsolutePosition().y + sfDEFAULT_ME_OFFSET))/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().y;
                        pShape->MoveBy(0, dy);
                    }
                }

                if(pShape->ContainsStyle(sfsSIZE_CHANGE))pShape->Scale(1, sy, sfWITHCHILDREN);
				
				if( ! pShape->ContainsStyle( sfsNO_FIT_TO_CHILDREN ) ) pShape->FitToChildren();
            }
            else
            {
                if(pShape->ContainsStyle(sfsPOSITION_CHANGE))
                {
                    pLine = (wxSFLineShape*)pShape;
                    ptnode = pLine->GetControlPoints().GetFirst();
                    while(ptnode)
                    {
                        pt = ptnode->GetData();
                        dy = handle.GetDelta().y - (pt->y - (GetAbsolutePosition().y + sfDEFAULT_ME_OFFSET))/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().y;
                        pt->y += dy;
                        pt->y = floor(pt->y);
                        ptnode = ptnode->GetNext();
                    }
                }
            }

            node = node->GetNext();
		}
	}
}
Exemple #3
0
void wxSFMultiSelRect::OnRightHandle(wxSFShapeHandle& handle)
{
	if(GetParentCanvas() && !AnyWidthExceeded(handle.GetDelta()))
	{
	    wxXS::RealPointList::compatibility_iterator ptnode;
	    wxSFLineShape* pLine;
	    wxRealPoint* pt;

		double dx, sx = (GetRectSize().x - 2*sfDEFAULT_ME_OFFSET + handle.GetDelta().x)/(GetRectSize().x - 2*sfDEFAULT_ME_OFFSET);

		ShapeList m_lstSelection;
		GetParentCanvas()->GetSelectedShapes(m_lstSelection);

		ShapeList::compatibility_iterator node = m_lstSelection.GetFirst();
		while(node)
		{
			wxSFShapeBase* pShape = node->GetData();

			// scale main parent shape
			if(!pShape->IsKindOf(CLASSINFO(wxSFLineShape)))
			{
			    dx = (pShape->GetAbsolutePosition().x - (GetAbsolutePosition().x + sfDEFAULT_ME_OFFSET))/(GetRectSize().x - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().x;

				if(pShape->ContainsStyle(sfsSIZE_CHANGE))pShape->Scale(sx, 1, sfWITHCHILDREN);
                if(pShape->ContainsStyle(sfsPOSITION_CHANGE))pShape->MoveBy(dx, 0);
				
				if( ! pShape->ContainsStyle( sfsNO_FIT_TO_CHILDREN ) ) pShape->FitToChildren();
			}
			else
			{
			    if(pShape->ContainsStyle(sfsPOSITION_CHANGE))
			    {
                    pLine = (wxSFLineShape*)pShape;
                    ptnode = pLine->GetControlPoints().GetFirst();
                    while(ptnode)
                    {
                        pt = ptnode->GetData();
                        dx = ( pt->x - (GetAbsolutePosition().x + sfDEFAULT_ME_OFFSET))/(GetRectSize().x - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().x;
                        pt->x += dx;
                        pt->x = floor(pt->x);
                        ptnode = ptnode->GetNext();
                    }
			    }
			}

			node = node->GetNext();
		}
	}
}
Exemple #4
0
void wxSFRectShape::OnBottomHandle(wxSFShapeHandle& handle)
{
	// HINT: overload it for custom actions...

	//m_nRectSize.y = handle.GetPosition().y - GetAbsolutePosition().y;
	m_nRectSize.y += handle.GetDelta().y;
}
Exemple #5
0
void wxSFRectShape::OnTopHandle(wxSFShapeHandle& handle)
{
	// HINT: overload it for custom actions...

    wxSFShapeBase *pChild;

	//double dy = (double)handle.GetPosition().y - GetAbsolutePosition().y;
	double dy = (double)handle.GetDelta().y;

	// update position of children
	if( !ContainsStyle( sfsLOCK_CHILDREN ) )
	{
		SerializableList::compatibility_iterator node = GetFirstChildNode();
		while(node)
		{
			pChild = (wxSFShapeBase*)node->GetData();
			if( pChild->GetVAlign() == valignNONE )
			{
				pChild->MoveBy(0, -dy);
			}
			node = node->GetNext();
		}
	}
	// update position and size of the shape
	m_nRectSize.y -= dy;
	m_nRelativePosition.y += dy;
}
Exemple #6
0
void wxSFRectShape::OnRightHandle(wxSFShapeHandle& handle)
{
	// HINT: overload it for custom actions...

	//m_nRectSize.x = handle.GetPosition().x - GetAbsolutePosition().x;
	m_nRectSize.x += handle.GetDelta().x;
}
Exemple #7
0
void wxSFRectShape::OnHandle(wxSFShapeHandle& handle)
{
    // HINT: overload it for custom actions...

	switch(handle.GetType())
	{
	case wxSFShapeHandle::hndLEFT:
		OnLeftHandle(handle);
		break;

	case wxSFShapeHandle::hndLEFTTOP:
		OnLeftHandle(handle);
		OnTopHandle(handle);
		break;

	case wxSFShapeHandle::hndLEFTBOTTOM:
		OnLeftHandle(handle);
		OnBottomHandle(handle);
		break;

	case wxSFShapeHandle::hndRIGHT:
		OnRightHandle(handle);
		break;

	case wxSFShapeHandle::hndRIGHTTOP:
		OnRightHandle(handle);
		OnTopHandle(handle);
		break;

	case wxSFShapeHandle::hndRIGHTBOTTOM:
		OnRightHandle(handle);
		OnBottomHandle(handle);
		break;

	case wxSFShapeHandle::hndTOP:
		OnTopHandle(handle);
		break;

	case wxSFShapeHandle::hndBOTTOM:
		OnBottomHandle(handle);
		break;

    default:
        break;
	}
	
	wxSFShapeBase::OnHandle( handle );
}
Exemple #8
0
void wxSFLineShape::OnHandle(wxSFShapeHandle& handle)
{
    switch(handle.GetType())
    {
    case wxSFShapeHandle::hndLINECTRL:
        {
            wxXS::RealPointList::compatibility_iterator node = m_lstPoints.Item(handle.GetId());
            if(node)
            {
                wxRealPoint* pt = node->GetData();
                pt->x = handle.GetPosition().x;
                pt->y = handle.GetPosition().y;
            }
        }
        break;

    case wxSFShapeHandle::hndLINEEND:
		{
			m_nUnfinishedPoint = handle.GetPosition();
			if( m_fStandAlone )	m_nTrgPoint = Conv2RealPoint( handle.GetPosition() );
		}
		break;
		
    case wxSFShapeHandle::hndLINESTART:
        {
			m_nUnfinishedPoint = handle.GetPosition();
			if( m_fStandAlone )	m_nSrcPoint = Conv2RealPoint( handle.GetPosition() );
        }
        break;

    default:
        break;
    }
	
	wxSFShapeBase::OnHandle( handle );
}
void SampleShape::OnEndHandle(wxSFShapeHandle& handle)
{
	wxSFSample2Frame::Log( wxSFSample2Frame::logHandleEvent, wxString::Format( wxT("Called handler: 'OnEndHandle()', Shape ID: %d, Handle type: %d\n"), GetId(), (int)handle.GetType() ) );
	
	// call original handler if required
	wxSFRectShape::OnEndHandle(handle);
}
Exemple #10
0
//**************************************************
void wxSFBotLineShape::OnEndHandle(wxSFShapeHandle& handle)
{
	wxSFShapeBase *pParent = GetParentCanvas()->GetShapeUnderCursor();
	if( pParent )
	{
		wxPoint lpos = /*wxSFShapeCanvas::DP2LP(*/handle.GetPosition()/*)*/;
		wxRect bbRect = pParent->GetBoundingBox();
		int centr = bbRect.GetPosition().x + (bbRect.GetWidth()/2);

		switch( handle.GetType() )
		{
			case wxSFShapeHandle::hndLINESTART:
				if( pParent->GetId() == m_nSrcShapeId )
				{
					if(pParent->IsKindOf(CLASSINFO(wxSFIfShape)))
					{
						wxSFIfShape *ifShape = (wxSFIfShape*)pParent;

						wxSFBotLineShape* pLine;
						ShapeList m_lstLines;
						if(GetShapeManager()->GetShapes(CLASSINFO(wxSFBotLineShape), m_lstLines))
						{
							ShapeList::compatibility_iterator node = m_lstLines.GetFirst();
							while(node)
							{
								pLine = (wxSFBotLineShape*)node->GetData();
								if(lpos.x <= centr) //True
								{
									if( (ifShape->GetId() == pLine->GetSrcShapeId()) &&
										(pLine->GetCondition() == 1) )	return;
								}
								else if(lpos.x > centr) //False
								{
									if( (ifShape->GetId() == pLine->GetSrcShapeId()) &&
										(pLine->GetCondition() == 0) )	return;
								}
								node = node->GetNext();
							}
						}

						if(lpos.x <= centr) //True
						{
							SetCondition(1);
						}
						else if(lpos.x > centr) //False
						{
							SetCondition(0);
						}
					}
				}
				break;
			case wxSFShapeHandle::hndLINEEND:
				if( pParent->GetId() == m_nTrgShapeId )
				{
					if(pParent->IsKindOf(CLASSINFO(wxSFIfShape)))
					{
						wxSFIfShape *ifShape = (wxSFIfShape*)pParent;

						wxSFBotLineShape* pLine;
						ShapeList m_lstLines;

						if(GetShapeManager()->GetShapes(CLASSINFO(wxSFBotLineShape), m_lstLines))
						{
							ShapeList::compatibility_iterator node = m_lstLines.GetFirst();
							while(node)
							{
								pLine = (wxSFBotLineShape*)node->GetData();
								if( pLine->GetTrgShapeId() == pParent->GetId() )
									return;
								node = node->GetNext();
							}
						}
					}

					wxSFShapeBase* pSourceShape = GetShapeManager()->FindShape(m_nSrcShapeId);
					if(pSourceShape->IsKindOf(CLASSINFO(wxSFCycle)))
					{
						//if(pSourceShape = pShapeUnder->GetParentShape())
						//	return;
					}
					else
					{
						if(!pSourceShape->GetParentShape())
							if(pParent->GetParentShape())
								return;
						if(pSourceShape->GetParentShape())
							if(!pParent->GetParentShape())
								return;
						if(pSourceShape->GetParentShape())
							if(pParent->GetParentShape())
								if(pParent->GetParentShape() != pSourceShape->GetParentShape())
									return;
					}

					if( !LineCanConnect(pParent) )
						return;
				}
				break;
			default:
				break;
		}
	}
	wxSFLineShape::OnEndHandle(handle);
}