コード例 #1
0
//////////////////////////////////////////////////////////////////////////
//@intro	鼠标移动事件
//@param	e:鼠标移动事件
//////////////////////////////////////////////////////////////////////////
void GLTextureArea::mouseMoveEvent(QMouseEvent *e) {
    double world_x,world_y,world_z;
    GetWorldCoordinate(e->x(), height()-e->y(),world_x,world_y,world_z);
    if(mLeftKeyPressed && mSelectedSliceIndex != -1 && mControlPointSelected == false) {
        mEnrolledSlices[mSelectedSliceIndex].Translate( (float)(world_x - oldX), (float)(world_y - oldY));
    }
    else if(mLeftKeyPressed && mSelectedSliceIndex != -1 && mControlPointSelected == true) {
        float oldUpperBound = mEnrolledSlices[mSelectedSliceIndex].GetUpperBound();
        float oldLowerBound = mEnrolledSlices[mSelectedSliceIndex].GetLowerBound();
        mEnrolledSlices[mSelectedSliceIndex].MoveEndPoint((float)world_x,(float)world_y);
        float newUpperBound = mEnrolledSlices[mSelectedSliceIndex].GetUpperBound();
        float newLowerBound = mEnrolledSlices[mSelectedSliceIndex].GetLowerBound();
        for(auto i = 0; i < mEnrolledSlices.size(); i++) {
            if(i < mSelectedSliceIndex) {
                mEnrolledSlices[i].Translate(0, newLowerBound - oldLowerBound);
            } else if(i > mSelectedSliceIndex) {
                mEnrolledSlices[i].Translate(0, newUpperBound - oldUpperBound);
            }
        }
        //mEnrolledSlices[mSelectedSliceIndex].MoveRightEndPoint((float)world_x,(float)world_y);
    }
    else if(mLeftKeyPressed && mSelectedSliceIndex == -1) {
        mTranslateX += (float)(world_x - oldX);
        mTranslateY += (float)(world_y - oldY);
    }
    oldX = static_cast<float>(world_x);
    oldY = static_cast<float>(world_y);
    updateGL();
}
コード例 #2
0
//////////////////////////////////////////////////////////////////////////
//@intro	当前控件的鼠标释放事件
//@param	e:鼠标释放控件
//////////////////////////////////////////////////////////////////////////
void GLTextureArea::mouseReleaseEvent(QMouseEvent *e) {
    double world_x,world_y,world_z;
    GetWorldCoordinate(e->x(), height()-e->y(),world_x,world_y,world_z);
    oldX = world_x;
    oldY = world_y;
    if(e->button()== Qt::LeftButton) {
        trackball.MouseUp(e->x(),height()-e->y(),QT2VCG(e->button(),e->modifiers()));
        mLeftKeyPressed = false;
        if(mSelectedSliceIndex != -1 && mControlPointSelected) {
            mEnrolledSlices[mSelectedSliceIndex].ResetControlPoint();
            mControlPointSelected = false;
        }
    }
    update();
    updateGL();
}
コード例 #3
0
//////////////////////////////////////////////////////////////////////////
//@intro	鼠标移动事件
//@param	e:鼠标移动事件
//////////////////////////////////////////////////////////////////////////
void GLTextureArea::mousePressEvent(QMouseEvent *e) {
    double world_x,world_y,world_z;
    GetWorldCoordinate(e->x(), height()-e->y(),world_x,world_y,world_z);
    if(e->button()==Qt::LeftButton) {
        mLeftKeyPressed = true;
        mSelectedSliceIndex = GetSelectedSlice((float)world_x,(float)world_y);
        if(mSelectedSliceIndex != -1) {
            if(mEnrolledSlices[mSelectedSliceIndex].IsControlEndSelected((float)world_x,(float)world_y)) {
                mControlPointSelected = true;
            } else {
                mControlPointSelected = false;
            }
        } else {
            mControlPointSelected = false;
        }
    }
    oldX = world_x;
    oldY = world_y;
    updateGL();
}
コード例 #4
0
ファイル: GraphFrame.cpp プロジェクト: alex-peng/AnimVis
void CGraphCanvas::OnMouse( wxMouseEvent& event )
{

	int mouse_x = event.GetX();
	int mouse_y = event.GetY();


	if(event.LeftDClick())
	{
		//if ( !m_if_dragging )
		{
			SetCurrent();
			GetWorldCoordinate( m_newOrtho[0], m_newOrtho[1], mouse_x, mouse_y );
			Refresh(false);
			m_if_choseDrag = true;
		}
	}
	else if(event.RightUp())
	{
 		m_if_choseDrag = false;
// 		m_node = -1;
//		GetWorldCoordinate( m_newOrtho_pre[2], m_newOrtho_pre[3], mouse_x, mouse_y );
	}
	else if(event.RightDown())
	{
	//	GetWorldCoordinate( m_newOrtho_pre[2], m_newOrtho_pre[3], mouse_x, mouse_y );
	}
 	
	else if(event.Dragging()&&event.RightIsDown())
	{
// 		if(m_if_choseDrag==false)
// 		{
// 			GetWorldCoordinate( m_newOrtho_pre[2], m_newOrtho_pre[3], mouse_x, mouse_y );
// 			GetWorldCoordinate( m_newOrtho[2], m_newOrtho[3], mouse_x, mouse_y );
// 			m_if_choseDrag = true;
// 			Refresh(false);
// 			return;
// 		}

		GetWorldCoordinate( m_newOrtho[2], m_newOrtho[3], mouse_x, mouse_y );
		CDataManager *dm = GetDataManager();
		for ( t_pickset::iterator psit = dm->m_pickset.begin(); psit != dm->m_pickset.end(); psit++ )
		{

			//float pos[2];
			int offset;
			if((*psit).first==dm->m_Graph.selected_item[0])
			{
				offset = dm->map_x[(*psit).second];
				//kind = 0;
			}
			else if((*psit).first==dm->m_Graph.selected_item[1])
			{
				offset = dm->map_y[(*psit).second];
				//kind = 1;
			}

			//pos[0] = dm->m_Graph.graph_node[offset].pos[0];
			//pos[1] = dm->m_Graph.graph_node[offset].pos[1];

			
			
			dm->m_Graph.graph_node[offset].pos[0] +=(m_newOrtho[2]-m_newOrtho_pre[2]);
		    dm->m_Graph.graph_node[offset].pos[1] +=(m_newOrtho[3]-m_newOrtho_pre[3]);
		}
		GetWorldCoordinate( m_newOrtho_pre[2], m_newOrtho_pre[3], mouse_x, mouse_y );
		Refresh();

// 		if(m_node>=0)
// 		{
// 			GetWorldCoordinate( m_newOrtho[2], m_newOrtho[3], mouse_x, mouse_y );
// 			CDataManager *dm =  GetDataManager();
// 			dm->m_Graph.graph_node[m_node].pos[0] = m_newOrtho[2];
// 			dm->m_Graph.graph_node[m_node].pos[1] = m_newOrtho[3];
// 			
// 			m_if_choseDrag = false;
// 		}
	}

	if ( event.MiddleDown())
	{
		if ( !m_if_dragging )
		{
			SetCurrent();
			GetWorldCoordinate( m_newOrtho[0], m_newOrtho[1], mouse_x, mouse_y );
			m_newOrtho[2] = m_newOrtho[0]; m_newOrtho[3] = m_newOrtho[1];
		}
	}
	else if ( event.Dragging() && event.MiddleIsDown() )
	{
		m_if_dragging = true;
		GetWorldCoordinate( m_newOrtho[2], m_newOrtho[3], mouse_x, mouse_y );
		Refresh(false);
	}
	else if ( event.MiddleUp() )
	{
		if ( m_if_dragging )
		{
			m_if_dragging = false;
			GetWorldCoordinate( m_newOrtho[2], m_newOrtho[3], mouse_x, mouse_y );
			if ( m_newOrtho[0] > m_newOrtho[2] )
			{
				m_Ortho[0] = m_newOrtho[2];
				m_Ortho[1] = m_newOrtho[0];
			}
			else
			{
				m_Ortho[0] = m_newOrtho[0];
				m_Ortho[1] = m_newOrtho[2];
			}
			if ( m_newOrtho[1] > m_newOrtho[3] )
			{
				m_Ortho[2] = m_newOrtho[3];
				m_Ortho[3] = m_newOrtho[1];
			}
			else
			{
				m_Ortho[2] = m_newOrtho[1];
				m_Ortho[3] = m_newOrtho[3];
			}
			Refresh(false);
		}
	}

	if ( event.LeftDown())
	{
		if ( !m_if_selecting )
		{
			SetCurrent();
			GetWorldCoordinate( m_newOrtho[0], m_newOrtho[1], mouse_x, mouse_y );
			m_newOrtho[2] = m_newOrtho[0]; m_newOrtho[3] = m_newOrtho[1];
		}
	}
	else if ( event.Dragging() && event.LeftIsDown() )
	{
		m_if_selecting = true;
		GetWorldCoordinate( m_newOrtho[2], m_newOrtho[3], mouse_x, mouse_y );
		Refresh(false);
	}
	else if ( event.LeftUp() )
	{
		if ( m_if_selecting )
		{
			m_if_selecting = false;
			GetWorldCoordinate( m_newOrtho[2], m_newOrtho[3], mouse_x, mouse_y );
			if ( m_newOrtho[0] > m_newOrtho[2] )
			{
				float tmp = m_newOrtho[0];
				m_newOrtho[0] = m_newOrtho[2];
				m_newOrtho[2] = tmp;
			}

			if ( m_newOrtho[1] > m_newOrtho[3] )
			{
				float tmp = m_newOrtho[3];
				m_newOrtho[3] = m_newOrtho[1];
				m_newOrtho[1] = tmp;
			}
				SelectData();

 				m_newOrtho_pre[2] = m_newOrtho[2] = (m_newOrtho[0] + m_newOrtho[2])*0.5f;
 				m_newOrtho_pre[3] = m_newOrtho[3] = (m_newOrtho[1] + m_newOrtho[3])*0.5f;
				
		}
	//	GetWorldCoordinate( m_newOrtho_pre[2], m_newOrtho_pre[3], mouse_x, mouse_y );
	//	Refresh(false);
		rf->m_cf->RefreshAll();
	}


}