📄 geneditview.cpp
字号:
if (LButtonIsDown)
{
LockAxisView (&dx, &dy);
ShearSelected (pDoc, dx, dy);
}
break;
default :
DoRedraw = FALSE;
break;
}
break;
case ID_TOOLS_TEMPLATE :
switch (Tool)
{
case ID_TOOLS_BRUSH_MOVEROTATEBRUSH :
if (LButtonIsDown)
{
LockAxis (&dv);
pDoc->MoveTemplateBrush(&dv);
}
break; // changed for g3dc
case ID_TOOLS_BRUSH_ROTATEBRUSH :
if (LButtonIsDown)
{
Render_ViewDeltaToRotation (VCam, (float)dx, &dv);
pDoc->RotateTemplateBrush(&dv);
}
break;
case ID_TOOLS_BRUSH_SCALEBRUSH :
if (LButtonIsDown)
{
LockAxisView (&dx, &dy);
ScaleSelected (pDoc, dx, dy);
}
break;
case ID_TOOLS_BRUSH_SHEARBRUSH :
if (LButtonIsDown)
{
LockAxisView (&dx, &dy);
ShearSelected (pDoc, dx, dy);
}
break;
default :
DoRedraw = FALSE;
break;
}
break;
default :
DoRedraw = FALSE;
break;
} // Mode Tool
}// Ortho Views
if (DoRedraw)
{
RedrawWindow();
}
POINT pt = mStartPoint; // The position works on the delta mStartPoint...
ClientToScreen( &pt ) ;
SetCursorPos( pt.x, pt.y );
}
#pragma warning (default:4100)
BOOL CGenEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint ptMouse)
{
CGenEditDoc *pDoc = GetDocument();;
geVec3d sp, wp, dv; // vectors for our movement calcs
int ModeTool = GetModeTool(); // our currently selected main tool
if (!mViewIs3d) // if we are in one of the ortho views
{
if (zDelta < 0) // NOTE: a forward roll-increment = zDelta = 120
OnViewZoomout(); // a backward roll-increment = zDelta = -120
if (zDelta > 0)
OnViewZoomin();
}
// restrict to Camera mode, otherwise too much confusion
// If the textured view is active,
// AND we are in Camera mode
if (/*(ModeTool == ID_TOOLS_CAMERA) &&*/ (mViewIs3d))
{
// get a vector for the mouse cursor in the view
Render_ViewToWorld(VCam, ptMouse.x, ptMouse.y, &sp);
// calc a delta factor that would advance to a new position
Render_ViewToWorld(VCam, ptMouse.x, (ptMouse.y + zDelta), &wp);
// calc the final vector location in world space
geVec3d_Subtract(&wp, &sp, &dv);
// send this info to Pan
//left right middle space
Pan (pDoc, 0, (-zDelta), &dv, TRUE, FALSE, FALSE, FALSE);
// now redraw the textured view
RedrawWindow();
}
return CView::OnMouseWheel(nFlags, zDelta, ptMouse);
}
void CGenEditView::OnMButtonDown(UINT nFlags, CPoint point)
{
SetCapture(); // capture the current mouse position
mStartPoint = point; // set the starting point to the current position
HideTheCursor(); // hide the cursor while we pan
}
void CGenEditView::OnMButtonUp(UINT nFlags, CPoint point)
{
ReleaseCapture(); // release control
ShowTheCursor(); // n'est pas?
}
void CGenEditView::DoZoom (float ZoomInc)
{
if (!mViewIs3d)
{
CGenEditDoc *pDoc = GetDocument ();
Render_ZoomChange( VCam, ZoomInc);
pDoc->UpdateGridInformation ();
RedrawWindow();
}
}
void CGenEditView::OnViewZoomin()
{
DoZoom (0.1f);
}
void CGenEditView::OnUpdateViewZoomin(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CGenEditView::OnViewZoomout()
{
DoZoom (-0.1f);
}
void CGenEditView::OnUpdateViewZoomout(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CGenEditView::HideTheCursor (void)
{
while (ShowCursor (FALSE) >= 0)
{
;
}
}
void CGenEditView::ShowTheCursor (void)
{
while (ShowCursor (TRUE) < 0)
{
;
}
}
// Snaps the closest edge to SnapSize.
static float ComputeSnap (float Cur, float Delta, float SnapSize)
{
float Target;
float SnapDelta;
float Remainder;
Target = Cur + Delta;
Remainder = (float)fmod (Target, SnapSize);
if (fabs (Remainder) < (SnapSize / 2.0f))
{
SnapDelta = -Remainder;
}
else
{
if (Target < 0.0f)
{
SnapDelta = -(SnapSize + Remainder);
}
else
{
SnapDelta = SnapSize - Remainder;
}
}
return SnapDelta;
}
static float SnapSide (float CurMin, float CurMax, float Delta, float SnapSize)
{
float MinDelta, MaxDelta;
MinDelta = ComputeSnap (CurMin, Delta, SnapSize);
MaxDelta = ComputeSnap (CurMax, Delta, SnapSize);
return (fabs (MinDelta) < fabs (MaxDelta)) ? MinDelta : MaxDelta;
}
void CGenEditView::DoneMovingBrushes ()
{
CGenEditDoc *pDoc = GetDocument ();
int ModeTool = GetModeTool ();
if (SelBrushList_GetSize (pDoc->pSelBrushes) > 0 || ModeTool == ID_TOOLS_TEMPLATE)
{
geFloat fSnapSize ;
const geVec3d *vMin, *vMax;
const Box3d *pBox;
geVec3d SnapDelta;
geBoolean SnapX, SnapY, SnapZ;
fSnapSize = 1.0f;
if (Level_UseGrid (pDoc->pLevel))
{
fSnapSize = Level_GetGridSnapSize (pDoc->pLevel);
}
// do the snap thing...
pBox = Brush_GetBoundingBox (pDoc->CurBrush);
vMin = Box3d_GetMin (pBox);
vMax = Box3d_GetMax (pBox);
geVec3d_Clear (&SnapDelta);
/*
In template mode, the brush is moved directly, so we have to snap to
the current position, not current position plus delta. Since we
clear the delta before computing the snap, we have to save these
flags.
*/
SnapX = (pDoc->FinalPos.X != 0.0f);
SnapY = (pDoc->FinalPos.Y != 0.0f);
SnapZ = (pDoc->FinalPos.Z != 0.0f);
if ((ModeTool == ID_TOOLS_TEMPLATE) || IsCopying)
{
geVec3d_Clear (&pDoc->FinalPos);
}
if (SnapX)
{
SnapDelta.X = ::SnapSide (vMin->X, vMax->X, pDoc->FinalPos.X, fSnapSize);
}
if (SnapY)
{
SnapDelta.Y = ::SnapSide (vMin->Y, vMax->Y, pDoc->FinalPos.Y, fSnapSize);
}
if (SnapZ)
{
SnapDelta.Z = ::SnapSide (vMin->Z, vMax->Z, pDoc->FinalPos.Z, fSnapSize);
}
if (ModeTool == ID_TOOLS_TEMPLATE)
{
pDoc->FinalPos = SnapDelta;
}
else
{
geVec3d_Add (&pDoc->FinalPos, &SnapDelta, &pDoc->FinalPos);
}
}
pDoc->DoneMove (); // already calls pDoc->UpdateSelected
// g3dc tuning comment
// pDoc->UpdateSelected(); // calls CMainFrame::UpdateMainControls
// g3dc tuning comment
// Since this function is called by OnLButtonUp, and that function already
// handles UpdateAllViews issues, the following calls to UpdateAllViews
// are redundant and unnecessary.
/* if ((ModeTool == ID_TOOLS_TEMPLATE) ||
((pDoc->GetSelState() & ANYENTITY) && (!(pDoc->GetSelState() & ANYBRUSH))) )
{
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
pDoc->UpdateAllViews( UAV_ALL3DVIEWS, NULL ); // old gedit
}
else
{
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// Make sure REBUILD_QUICK is absolutely necessary.
pDoc->UpdateAllViews( UAV_ALL3DVIEWS | REBUILD_QUICK, NULL );
}
*/
}
#pragma warning (disable:4100)
#pragma warning (disable:4806)
void CGenEditView::OnLButtonUp(UINT nFlags, CPoint point)
{
BOOL bWasCaptured = FALSE ;
CGenEditDoc* pDoc;
int ModeTool;
int Tool;
fdocAdjustEnum AdjustMode;
ModeTool = GetModeTool ();
Tool = GetTool ();
pDoc = GetDocument ();
AdjustMode = GetAdjustMode ();
LMouseButtonDown = GE_FALSE;
if (!RMouseButtonDown)
{
// right mouse button isn't down
if(this == GetCapture ())
{
bWasCaptured = TRUE ;
ReleaseCapture();
}
if (IsKeyDown (VK_SPACE) || IsPanning || ModeTool == ID_TOOLS_CAMERA)
{
/*
Ok, here's the scoop.
If we're in the middle of a move/rotate and the user mashes the space bar,
we all of a sudden end up in panning mode with no context information to
tell us that we were previously moving/rotating. So we end up with the
original brushes in the world, and the temporary brushes that are selected
and being moved also in the world. So here we do a TempDeleteSelected to
remove those temporary brushes. Otherwise they'd hang around forever.
Ideally, the move/rotate would be separated from the panning so that we could
move and pan at the same time. Of course, I'd like to get rid of the whole
temp selected thing, too, but that'll have to wait...
*/
pDoc->TempDeleteSelected();
IsPanning = FALSE;
ShowTheCursor ();
RedrawWindow();
return;
} // IsKeyDown()
if (mViewIs3d) // we just clicked the textered view
{
if(ModeTool==ID_TOOLS_TEMPLATE && pDoc->TempEnt)
{
pDoc->PlaceTemplateEntity3D(point, VCam);
}
else if (IsKeyDown (VK_SHIFT))
{
pDoc->SelectTextureFromFace3D (point, VCam);
}
else
{
switch (AdjustMode)
{
case ADJUST_MODE_BRUSH :
case ADJUST_MODE_FACE :
pDoc->SelectRay (point, VCam); // calls UpdateSelected()
// pDoc->UpdateAllViews (UAV_ALL3DVIEWS , NULL); //old gedit
// new g3dc
// critical for selecting brushes in textured view and
// and for getting the correct face information
// if ((!pDoc->GetSelState() & ANYBRUSH) || (pDoc->GetSelState() & ANYFACE))
{ // if face is selected and brush is not
// absolutely necessary in order to conserve brush and
// face dialog information
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
pDoc->UpdateAllViews( UAV_ALLVIEWS, NULL );
}
// g3dc tuning else
// { // if brush is selected but face is not
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// Make sure REBUILD_QUICK is absolurelty necessary.
// pDoc->UpdateAllViews( UAV_ALL3DVIEWS | REBUILD_QUICK, NULL );
// }
// end add for g3dc
break;
default :
break;
}
}
}
else // we just clicked on one of the 3 ortho views
{
switch (Tool)
{
case CURTOOL_NONE :
if (AdjustMode == ADJUST_MODE_BRUSH)
{
if( IsDragging )
{ // calls UpdateSelected()
pDoc->SelectOrthoRect( mDragStartPoint, mDragCurrentPoint, VCam );
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
pDoc->UpdateAllViews(UAV_ALL3DVIEWS, NULL);
IsDragging = FALSE ;
}
else if(IsCopying)
{ // calls DoneMove() which calls UpdateSelected()
// which calls UpdateMainControls()
DoneMovingBrushes ();
IsCopying = FALSE;
}
else
{
pDoc->SelectOrtho(point, VCam); // calls UpdateSelected()
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
pDoc->UpdateAllViews( UAV_ALL3DVIEWS, NULL );
}
}
else
{
MessageBeep ((UINT)(-1));
}
break;
case ID_TOOLS_BRUSH_MOVEROTATEBRUSH :
case ID_TOOLS_BRUSH_MOVESELECTEDBRUSHES :
DoneMovingBrushes (); // calls pDoc->UpdateSelected
if ((ModeTool == ID_TOOLS_TEMPLATE) ||
((pDoc->GetSelState() & ANYENTITY) && (!(pDoc->GetSelState() & ANYBRUSH))) )
{
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
pDoc->UpdateAllViews( UAV_ALL3DVIEWS, NULL ); // old gedit
}
else
{
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// Make sure REBUILD_QUICK is absolutely necessary.
pDoc->UpdateAllViews( UAV_ALL3DVIEWS | REBUILD_QUICK, NULL );
}
break;
// new g3dc to accomodate the new Rotate tool
case ID_TOOLS_BRUSH_ROTATEBRUSH:
{
pDoc->UpdateSelected(); // calls UpdateMainControls()
if (GetModeTool () == ID_GENERALSELECT)
{
pDoc->DoneRotate (); //calls UpdateSelected
}
if (SelBrushList_GetSize (pDoc->pSelBrushes) != 0)
// Be very careful when speccing flags for UpdateAllViews()
// The wrong flags at the wrong time will totally screw things up
// Make sure REBUILD_QUICK is absolutely necessary.
pDoc->UpdateAllViews(UAV_ALL3DVIEWS | REBUILD_QUICK, NULL);
else
pDoc->UpdateAllViews( UAV_ALL3DVIEWS, NULL );
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -