VTK屏幕坐标与世界坐标转换(Qt)-创新互联
void VtkMPRWidget::mousePressEvent( QMouseEvent* event ) { m_bPressed = true; m_pressPoint = event->pos(); } void VtkMPRWidget::mouseMoveEvent( QMouseEvent* event ) { if( !m_bPressed ) return; m_movePoint = event->pos(); int nHeight = height(); double* dPressValue; double* dMoveValue; vtkSmartPointer创新互联主营蠡县网站建设的网络公司,主营网站建设方案,重庆APP开发,蠡县h5小程序开发搭建,蠡县网站营销推广欢迎蠡县等地区企业咨询pCoorPress = vtkSmartPointer ::New(); pCoorPress->SetCoordinateSystemToDisplay(); pCoorPress->SetValue( m_pressPoint.x(), nHeight - m_pressPoint.y(), 0.0 ); dPressValue = pCoorPress->GetComputedWorldValue( m_pRenderer ); vtkSmartPointer pCoorMove = vtkSmartPointer ::New(); pCoorMove->SetCoordinateSystemToDisplay(); pCoorMove->SetValue( m_movePoint.x(), nHeight - m_movePoint.y(), 0.0 ); dMoveValue = pCoorMove->GetComputedWorldValue( m_pRenderer ); double dPressVal[3] = { dPressValue[0], dPressValue[1], dPressValue[2] }; double dMoveVal[3] = { dMoveValue[0], dMoveValue[1], dMoveValue[2] }; vtkSmartPointer pPoints = vtkSmartPointer ::New(); pPoints->InsertNextPoint( dPressVal[0], dPressVal[1], 0.0 ); pPoints->InsertNextPoint( dPressVal[0], dMoveVal[1], 0.0 ); pPoints->InsertNextPoint( dMoveVal[0], dMoveVal[1], 0.0 ); pPoints->InsertNextPoint( dMoveVal[0], dPressVal[1], 0.0 ); vtkSmartPointer line1 = vtkSmartPointer ::New(); line1->GetPointIds()->SetId( 0, 0 ); line1->GetPointIds()->SetId( 1, 1 ); vtkSmartPointer line2 = vtkSmartPointer ::New(); line2->GetPointIds()->SetId( 0, 1 ); line2->GetPointIds()->SetId( 1, 2 ); vtkSmartPointer line3 = vtkSmartPointer ::New(); line3->GetPointIds()->SetId( 0, 2 ); line3->GetPointIds()->SetId( 1, 3 ); vtkSmartPointer line4 = vtkSmartPointer ::New(); line4->GetPointIds()->SetId( 0, 3 ); line4->GetPointIds()->SetId( 1, 0 ); vtkSmartPointer lineArray = vtkSmartPointer ::New(); lineArray->InsertNextCell( line1 ); lineArray->InsertNextCell( line2 ); lineArray->InsertNextCell( line3 ); lineArray->InsertNextCell( line4 ); if( NULL == m_pPolyData ) { m_pPolyData = vtkSmartPointer ::New(); m_pPolyData->SetPoints( pPoints ); m_pPolyData->SetLines( lineArray ); m_pPolyData->Modified(); vtkSmartPointer mapper = vtkSmartPointer ::New(); mapper->SetInputData( m_pPolyData ); vtkSmartPointer actor = vtkSmartPointer ::New(); actor->SetMapper( mapper ); actor->GetProperty()->SetLineWidth( 1.5 ); actor->GetProperty()->SetColor( 0.3, 0.8, 0.0 ); m_pRenderer->AddActor( actor ); m_pRenderer->Modified(); m_pRednerWindow->Modified(); m_pRednerWindow->Render(); return; } m_pPolyData->SetPoints( pPoints ); m_pPolyData->SetLines( lineArray ); m_pPolyData->Modified(); m_pRednerWindow->Modified(); m_pRednerWindow->Render(); } void VtkMPRWidget::mouseReleaseEvent( QMouseEvent* event ) { m_bPressed = false; m_pPolyData = NULL; //FireObjectChanged(); }
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
当前文章:VTK屏幕坐标与世界坐标转换(Qt)-创新互联
分享地址:http://hbruida.cn/article/cddddd.html