void VisitPointTool::UpdateText() { char str[100]; double px = hotPoints[0].pt.x; double py = hotPoints[0].pt.y; double pz = hotPoints[0].pt.z; if (proxy.GetFullFrameMode()) { double scale; int type; proxy.GetScaleFactorAndType(scale, type); if (type == 0 ) // x_axis px /= scale; else // y_axis py /= scale; } double axisscale[3]; if (proxy.Get3DAxisScalingFactors(axisscale)) { px /= axisscale[0]; py /= axisscale[1]; pz /= axisscale[2]; } sprintf(str, "XYZ<%1.3g %1.3g %1.3g>", px, py, pz); pointTextActor->SetInput(str); avtVector originScreen = ComputeWorldToDisplay(hotPoints[0].pt); double pt[3] = {originScreen.x, originScreen.y, 0.}; pointTextActor->GetPositionCoordinate()->SetValue(pt); }
void vtkInteractorStyleQuench::Pan() { if (CurrentRenderer == NULL) return; vtkRenderWindowInteractor *rwi = this->Interactor; double viewFocus[4], focalDepth, viewPoint[3]; double newPickPoint[4], oldPickPoint[4], motionVector[3]; // Calculate the focal depth since we'll be using it a lot vtkCamera *camera = CurrentRenderer->GetActiveCamera(); camera->GetFocalPoint(viewFocus); ComputeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2], viewFocus); focalDepth = viewFocus[2]; ComputeDisplayToWorld((double)rwi->GetEventPosition()[0], (double)rwi->GetEventPosition()[1], focalDepth, newPickPoint); // Has to recalc old mouse point since the viewport has moved, // so can't move it outside the loop ComputeDisplayToWorld((double)rwi->GetLastEventPosition()[0], (double)rwi->GetLastEventPosition()[1], focalDepth, oldPickPoint); // Camera motion is reversed motionVector[0] = oldPickPoint[0] - newPickPoint[0]; motionVector[1] = oldPickPoint[1] - newPickPoint[1]; motionVector[2] = oldPickPoint[2] - newPickPoint[2]; camera->GetFocalPoint(viewFocus); camera->GetPosition(viewPoint); camera->SetFocalPoint(motionVector[0] + viewFocus[0], motionVector[1] + viewFocus[1], motionVector[2] + viewFocus[2]); camera->SetPosition(motionVector[0] + viewPoint[0], motionVector[1] + viewPoint[1], motionVector[2] + viewPoint[2]); if (AutoAdjustCameraClippingRange) CurrentRenderer->ResetCameraClippingRange(); if (rwi->GetLightFollowCamera()) CurrentRenderer->UpdateLightsGeometryToFollowCamera(); CurrentRenderer->GetRenderWindow()->Render(); }
void VisitPointTool::Translate(CB_ENUM e, int ctrl, int shift, int x, int y, int) { if (axisTranslate == none) { if (shift && !ctrl) if (window3D) axisTranslate = inAndOut; else axisTranslate = none; else if (shift && ctrl) axisTranslate = leftAndRight; else if (ctrl) axisTranslate = upAndDown; else axisTranslate = none; } if(e == CB_START) { vtkRenderer *ren = proxy.GetCanvas(); vtkCamera *camera = ren->GetActiveCamera(); double ViewFocus[3]; camera->GetFocalPoint(ViewFocus); ComputeWorldToDisplay(ViewFocus[0], ViewFocus[1], ViewFocus[2], ViewFocus); // Store the focal depth. focalDepth = ViewFocus[2]; if (axisTranslate != none) { translationDistance = ComputeTranslationDistance(axisTranslate); } // Make the right actors active. InitialActorSetup(); } else if(e == CB_MIDDLE) { avtVector newPoint = ComputeDisplayToWorld(avtVector(x,y,focalDepth)); // // Have to recalculate the old mouse point since the viewport has // moved, so we can't move it outside the loop // avtVector oldPoint = ComputeDisplayToWorld(avtVector(lastX,lastY,focalDepth)); avtVector motion(newPoint - oldPoint); if (axisTranslate) { double delta; if (axisTranslate == leftAndRight) delta = x - lastX; else delta = y - lastY; motion = translationDistance * delta; } hotPoints[0].pt = (hotPoints[0].pt + motion); // Update the text actors. UpdateText(); // Update the guide and the sphere. UpdateGuide(); UpdateSphere(); // Render the window proxy.Render(); if (proxy.GetToolUpdateMode() == UPDATE_CONTINUOUS) CallCallback(); } else { // Call the tool's callback. if (proxy.GetToolUpdateMode() != UPDATE_ONCLOSE) CallCallback(); // Remove the right actors. FinalActorSetup(); axisTranslate = none; } }