📄 geneditview.cpp
字号:
if (pMousePos->x < 0 || pMousePos->y < 0)
{
return;
}
CursorIndex = GetCursorBoxPos (pMousePos);
switch (Tool)
{
case ID_TOOLS_BRUSH_SCALEBRUSH :
// Scaling it's just a simple lookup
WhichCursor = SizeCursors [CursorIndex];
break;
case ID_TOOLS_BRUSH_SHEARBRUSH :
WhichCursor = ShearCursors[CursorIndex];
break;
default :
assert (0);
break;
}
SetCursor (AfxGetApp()->LoadStandardCursor (WhichCursor));
}
void CGenEditView::Pan(
CGenEditDoc *pDoc,
int dx, int dy,
const geVec3d *dv,
BOOL LButtonIsDown,
BOOL RButtonIsDown,
BOOL MButtonIsDown,
BOOL SpaceIsDown
)
{
if(mViewIs3d)
{
geVec3d MoveVec;
// if the left mouse button is down AND the spacebar is down,
// OR if the mousewheel button is down
if((LButtonIsDown && SpaceIsDown) || (MButtonIsDown))
{
geVec3d_Set (&MoveVec, (float)-dx, (float)-dy, 0.0f);
Render_MoveCamPos( VCam, &MoveVec ) ;
pDoc->UpdateCameraEntity( VCam ) ;
}
else if (LButtonIsDown && !SpaceIsDown)
{
geVec3d_Set (&MoveVec, 0.0f, 0.0f, (float)-dy);
Render_MoveCamPos( VCam, &MoveVec ) ;
if (Render_UpIsDown (VCam))
{
Render_IncrementYaw (VCam, (float)(-dx));
}
else
{
Render_IncrementYaw(VCam, (float)dx);
}
pDoc->UpdateCameraEntity( VCam ) ;
}
/*
else if (RButtonIsDown && SpaceIsDown)
{
}
*/ else if (RButtonIsDown)
{
if (Render_UpIsDown (VCam))
{
Render_IncrementYaw (VCam, (float)(-dx));
}
else
{
Render_IncrementYaw(VCam, (float)dx);
}
Render_IncrementPitch(VCam, (float)dy);
pDoc->UpdateCameraEntity( VCam ) ;
}
}
else // we are in one of the ortho views
{
geVec3d dcamv;
geVec3d_Scale (dv, -1.0f, &dcamv);
if (
(
( (LButtonIsDown && SpaceIsDown) || MButtonIsDown) && pDoc->mModeTool != ID_TOOLS_CAMERA)
||
(
( (LButtonIsDown || MButtonIsDown) && pDoc->mModeTool == ID_TOOLS_CAMERA)
)
)
{
Render_MoveCamPosOrtho(VCam, &dcamv); // pan the camera
}
else if (RButtonIsDown)
{
Render_ZoomChange(VCam, -(((float)dy) * 0.001f)); // zoom
pDoc->UpdateGridInformation ();
}
}
}
void CGenEditView::ScaleSelected (CGenEditDoc *pDoc, int dx, int dy)
{
//smooth out the zoom scale curve with a scalar
float ZoomInv =Render_GetZoom(VCam);
ZoomInv =(ZoomInv > .5)? 0.5f / ZoomInv : 1.0f;
// negated here because Brush_Resize is still thinking weird
pDoc->ResizeSelected (-(((float)dx)*ZoomInv), -(((float)dy)*ZoomInv), sides, Render_GetInidx(VCam));
}
void CGenEditView::ShearSelected (CGenEditDoc *pDoc, int dx, int dy)
{
//smooth out the zoom scale curve with a scalar
float ZoomInv =Render_GetZoom(VCam);
ZoomInv =(ZoomInv > .5)? 0.5f / ZoomInv : 1.0f;
pDoc->ShearSelected(-(((float)dy)*ZoomInv), -(((float)dx)*ZoomInv), sides, Render_GetInidx(VCam));
}
#pragma warning (disable:4100)
void CGenEditView::OnMouseMove (UINT nFlags, CPoint point)
{
int dx, dy;
geVec3d sp, wp, dv;
CGenEditDoc *pDoc;
geBoolean ShiftHeld;
geBoolean ControlHeld;
geBoolean LButtonIsDown, RButtonIsDown, MButtonIsDown;
geBoolean SpaceHeld;
BOOL ThisIsCaptured;
int ModeTool, Tool;
fdocAdjustEnum AdjustMode;
BOOL DoRedraw = TRUE;
POINT RealCursorPosition;
pDoc =GetDocument();
ThisIsCaptured = (this == GetCapture ());
ModeTool = GetModeTool ();
Tool = GetTool ();
AdjustMode = GetAdjustMode ();
/*
You'll notice here that we don't use the nFlags parameter to get these
settings. Those flags tell what the state of things was when the
MouseMove message was received, which could have been several seconds
ago (due to delays caused by a mashed key, for example). What we're
really interested is the current state, so we can throw out old messages.
*/
ShiftHeld = IsKeyDown (VK_SHIFT);
ControlHeld = IsKeyDown (VK_CONTROL);
LButtonIsDown = IsKeyDown (VK_LBUTTON);
RButtonIsDown = IsKeyDown (VK_RBUTTON);
SpaceHeld = IsKeyDown (VK_SPACE);
MButtonIsDown = IsKeyDown (VK_MBUTTON);
// new g3dc -- automatically activate pane if mouse is over it
CDC *pDC;
CWnd *pWnd;
CRect rect;
switch( mViewType )
{
case ID_VIEW_3DWIREFRAME:
case ID_VIEW_TEXTUREVIEW:
{
CSplitterWnd *pParent = STATIC_DOWNCAST(CSplitterWnd, GetParent());
int row = TEXTURE_VIEW_ROW;
int col = TEXTURE_VIEW_COL;
VERIFY(pParent->IsChildPane(this, row, col));
pWnd = pParent->GetPane(row,col);
// if the active pane is not the pane for this view
if (pParent->GetActivePane(&row, &col) != pWnd)
{
// make the pane for this view the active pane
pDC = pWnd->GetDC();
pDC->GetClipBox(rect);
pParent->SetActivePane(row,col, this);
}
break;
}
case ID_VIEW_TOPVIEW:
{
CSplitterWnd *pParent = STATIC_DOWNCAST(CSplitterWnd, GetParent());
int row = TOP_VIEW_ROW;
int col = TOP_VIEW_COL;
VERIFY(pParent->IsChildPane(this, row, col));
pWnd = pParent->GetPane(row,col);
// if the active pane is not the pane for this view
if (pParent->GetActivePane(&row, &col) != pWnd)
{
// make the pane for this view the active pane
pDC = pWnd->GetDC();
pDC->GetClipBox(rect);
pParent->SetActivePane(row,col, this);
}
break;
}
case ID_VIEW_FRONTVIEW:
{
CSplitterWnd *pParent = STATIC_DOWNCAST(CSplitterWnd, GetParent());
int row = FRONT_VIEW_ROW;
int col = FRONT_VIEW_COL;
VERIFY(pParent->IsChildPane(this, row, col));
pWnd = pParent->GetPane(row,col);
// if the active pane is not the pane for this view
if (pParent->GetActivePane(&row, &col) != pWnd)
{
// make the pane for this view the active pane
pDC = pWnd->GetDC();
pDC->GetClipBox(rect);
pParent->SetActivePane(row,col, this);
}
break;
}
case ID_VIEW_SIDEVIEW:
{
CSplitterWnd *pParent = STATIC_DOWNCAST(CSplitterWnd, GetParent());
int row = SIDE_VIEW_ROW;
int col = SIDE_VIEW_COL;
VERIFY(pParent->IsChildPane(this, row, col));
pWnd = pParent->GetPane(row,col);
// if the active pane is not the pane for this view
if (pParent->GetActivePane(&row, &col) != pWnd)
{
// make the pane for this view the active pane
pDC = pWnd->GetDC();
pDC->GetClipBox(rect);
pParent->SetActivePane(row,col, this);
}
break;
}
}
// IsPanning is true if any of the following conditions:
// 1. if either the spacebar is being held down or if we are
// just continuing on with a previously established state
// of IsPanning ---AND--- both left and righ mouse buttons
// are held down ---AND--- the mouse recently clicked in
// the view ---AND--- the view is the textured view.
// 2. The mousewheel button is down.Whenever the mousewheel
// button is down, we will be able to pan regardless of
// which view we are in.
IsPanning = (
((SpaceHeld || IsPanning) &&
(LButtonIsDown | RButtonIsDown) && ThisIsCaptured /*&& mViewIs3d*/)
|| (MButtonIsDown) // or if the mousewheel button is depressed
);
// if neither left mouse button nor mousewheel button
// have been clicked while the cursor is in this view
if (!ThisIsCaptured && !MButtonIsDown)
{
// Mouse isn't captured. So we're just moving the mouse around
// in this view. If we're not in camera mode and not panning,
// then set the cursor accordingly and exit.
if(!((ModeTool == ID_TOOLS_CAMERA) || IsPanning))
{
int Tool;
Tool = GetTool ();
if (mViewIs3d)
{
if (ShiftHeld)
{
SetCursor (AfxGetApp()->LoadCursor (IDC_EYEDROPPER));
}
else
{
SetCursor (AfxGetApp()->LoadStandardCursor (IDC_ARROW));
}
}
// post 0.5 release // grouped under !mViewIs3d
if (!mViewIs3d)
{
if ((Tool == ID_TOOLS_BRUSH_SCALEBRUSH) || (Tool == ID_TOOLS_BRUSH_SHEARBRUSH))
{
SetEditCursor (Tool, &point);
}
else if(Tool == ID_TOOLS_BRUSH_MOVEROTATEBRUSH) // NEW G3DC
SetCursor(AfxGetApp()->LoadCursor(IDC_MOVESELECT)); // NEW G3DC
else if(Tool == ID_TOOLS_BRUSH_ROTATEBRUSH) // NEW G3DC
SetCursor(AfxGetApp()->LoadCursor(IDC_ROTATE)); // NEW G3DC
else
SetCursor (AfxGetApp()->LoadStandardCursor (IDC_ARROW)); // NEW G3DC
}
}
return;
}
// otherwise either the mouse left button or the mousewheel button
// were clicked while the cursor was in this view
if(this==GetParentFrame()->GetActiveView())
{
pDoc->mActiveView =mViewType;
}
/*
The point parameter to this message gives us the mouse position when the
message was received. That could be old. We really want the *current*
position, so we get it here and convert it to client coordinates. This
prevents the panning runaway bug that plauged us for so long.
*/
::GetCursorPos (&RealCursorPosition);
ScreenToClient (&RealCursorPosition);
dx = (RealCursorPosition.x - mStartPoint.x);
dy = (RealCursorPosition.y - mStartPoint.y);
if ((dx == 0) && (dy == 0)) // don't do anything if no delta
{
return;
}
Render_ViewToWorld(VCam, mStartPoint.x, mStartPoint.y, &sp);
Render_ViewToWorld(VCam, RealCursorPosition.x, RealCursorPosition.y, &wp);
geVec3d_Subtract(&wp, &sp, &dv); // delta in world space
// if in Camera mode or if in Panning mode
// then pan in in the active view (includes all 4 views)
// if ((ModeTool == ID_TOOLS_CAMERA)||IsPanning)
// the heck with it. We want the camera in all modes
// if we are in camera mode, then pan regardless of the active view
// if we are in either Brush or Templates mode, then Pan as long as
// we are in the textured view and not in the ortho views.
// Or if we passed the IsPanning() test above.
if ((ModeTool == ID_TOOLS_CAMERA) ||
(ID_TOOLS_TEMPLATE && mViewIs3d) ||
(ID_GENERALSELECT && mViewIs3d) ||
IsPanning)
{
Pan (pDoc, dx, dy, &dv, LButtonIsDown, RButtonIsDown, MButtonIsDown, SpaceHeld);
}
// if it's one of the ortho views and not the textured view
else if (!mViewIs3d)
// none of this stuff should be available in the 3d view.
{
switch (ModeTool)
{
case ID_GENERALSELECT :
switch (Tool)
{
case CURTOOL_NONE :
// no tool selected. We're doing a drag select or clone operation
if (AdjustMode == ADJUST_MODE_BRUSH)
{
// drag select or cloning
if( IsDragging )
{
mDragCurrentPoint.x += (long)dx ;
mDragCurrentPoint.y += (long)dy ;
}
else if( !IsCopying && !ShiftHeld && !RButtonIsDown )
{
#pragma message ("Logic flawed here when space being held. Don't know exactly what.")
if((abs(dx) > mCX_DRAG) || (abs(dy) > mCY_DRAG))
{
mDragCurrentPoint = RealCursorPosition;
IsDragging = TRUE ;
}
}// Drag Select
else
{ // Begin a copy operation
if((LButtonIsDown && ShiftHeld)&&(!IsCopying))
{
IsCopying =TRUE;
pDoc->CopySelectedBrushes();
if (SelBrushList_GetSize (pDoc->pSelBrushes) > 0)
{
// make current brush point to first brush in list
// so we can snap correctly.
pDoc->CurBrush = SelBrushList_GetBrush (pDoc->pSelBrushes, 0);
}
}
if(IsCopying)
{
LockAxis( &dv ) ;
if(LButtonIsDown)
{
pDoc->MoveSelectedClone(&dv);
}
SetTool(CURTOOL_NONE);
}
}// Not Drag Select
}
break;
// REVISED FOR G3DC
case ID_TOOLS_BRUSH_MOVEROTATEBRUSH :
// moving/rotating brushes and entities
SetTool(ID_TOOLS_BRUSH_MOVESELECTEDBRUSHES);
if (LButtonIsDown)
{
LockAxis( &dv ) ;
pDoc->MoveSelectedBrushes(&dv);
}// LButtonDown
SetTool(ID_TOOLS_BRUSH_MOVEROTATEBRUSH);
break;
// NEW FOR G3DC
case ID_TOOLS_BRUSH_ROTATEBRUSH:
{
if (LButtonIsDown)
{
if( pDoc->GetSelState() == ONEENTITYONLY ) // Angle,Arc,Radius control
{
if( !ShiftHeld && !ControlHeld )
{
pDoc->AdjustEntityAngle( VCam, (float)dx ) ;
}
else if( ShiftHeld && !ControlHeld )
{
pDoc->AdjustEntityArc( VCam, (float)dx ) ;
}
else if( !ShiftHeld && ControlHeld )
{
pDoc->AdjustEntityRadius( &dv ) ;
}
}
else
{
Render_ViewDeltaToRotation (VCam, (float)dx, &dv);
pDoc->RotateSelectedBrushes(&dv);
}
}// LButtonDown
SetTool(ID_TOOLS_BRUSH_ROTATEBRUSH);
}
break;
case ID_TOOLS_BRUSH_SCALEBRUSH :
if (LButtonIsDown)
{
LockAxisView (&dx, &dy);
ScaleSelected (pDoc, dx, dy);
}
break;
case ID_TOOLS_BRUSH_SHEARBRUSH :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -