X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmapview.cpp;h=f745caf9cd36f238f976b73afaaf3189e9b0ccb4;hb=refs%2Ftags%2Fv3.0.2;hp=6e1199fa87e61242c8b3a075071fa2de4738c287;hpb=ae70f6ff733c4642fe3a9f8b3635a0a0b40cf82a;p=guemap diff --git a/src/mapview.cpp b/src/mapview.cpp index 6e1199f..f745caf 100644 --- a/src/mapview.cpp +++ b/src/mapview.cpp @@ -20,7 +20,6 @@ #include "roomdialog.h" #include "undo.h" - const int penEdgeWidth = 9, penPageWidth = 20, @@ -53,7 +52,6 @@ static const DirectionName directions[] = { static const char a2z[] = "abcdefghijklmnopqrstuvwxyz"; - // // Parse a direction word: // @@ -89,7 +87,6 @@ RoomCorner parseDirection(string & text) return rcNone; } - #if 0 ///////////////////////////////////////////////////////////////////////////// // CRepaginateDlg dialog @@ -122,8 +119,6 @@ class CRepaginateDlg : public CDialog }; #endif - - ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // CMapView @@ -360,14 +355,12 @@ MapView::MapView(QWidget * parent/*= NULL*/): QWidget(parent), mapContextMenu->addAction(deleteRoomAct); } - MapView::~MapView() { delete doc; // gueApp()->closingView(this); // Remove any comment for this view } - void MapView::DrawArrowhead(QPainter * painter, QPointF head, QPointF tail) { QPolygonF arrow; @@ -387,7 +380,6 @@ void MapView::DrawArrowhead(QPainter * painter, QPointF head, QPointF tail) painter->drawPolygon(arrow); } - void MapView::DrawNoExit(QPainter * painter, QPointF head, QPointF tail) { const double angle = Angle(tail - head); @@ -403,7 +395,6 @@ void MapView::DrawNoExit(QPainter * painter, QPointF head, QPointF tail) painter->drawLine(p2, p3); } - // // MapView drawing // @@ -736,9 +727,6 @@ printf(" clip = %i, %i, %i, %i; docSize = %i, %i\n", clip.left(), clip.right( QPoint ex = QPoint(0, 0); double angle = Angle(end - start); - if (angle < 0) - angle += TAU; - // Adjust text position if it runs into an edge if (((edge->end1 == rcNNW || edge->end1 == rcN || edge->end1 == rcNNE) && (angle > THREE_QTR_TAU && angle < TAU)) || ((edge->end1 == rcSSW || edge->end1 == rcS || edge->end1 == rcSSE) && (angle > QTR_TAU && angle < HALF_TAU)) @@ -753,14 +741,12 @@ printf(" clip = %i, %i, %i, %i; docSize = %i, %i\n", clip.left(), clip.right( dc->drawText(p + edgLblOffset[edge->end1] + ex, elBuf); } - if (edge->type2 & etDirection) + // Make sure there's an actual room #2 for this edge... + if (!(edge->type1 & etNoRoom2) && (edge->type2 & etDirection)) { QPoint ex = QPoint(0, 0); double angle = Angle(start - end); - if (angle < 0) - angle += TAU; - // Adjust text position if it runs into an edge if (((edge->end2 == rcNNW || edge->end2 == rcN || edge->end2 == rcNNE) && (angle > THREE_QTR_TAU && angle < TAU)) || ((edge->end2 == rcSSW || edge->end2 == rcS || edge->end2 == rcSSE) && (angle > QTR_TAU && angle < HALF_TAU)) @@ -891,7 +877,6 @@ printf(" clip = %i, %i, %i, %i; docSize = %i, %i\n", clip.left(), clip.right( } } - void MapView::keyPressEvent(QKeyEvent * event) { bool oldShift = shiftDown; @@ -975,7 +960,6 @@ void MapView::keyPressEvent(QKeyEvent * event) #endif } - void MapView::keyReleaseEvent(QKeyEvent * event) { bool oldShift = shiftDown; @@ -1006,7 +990,6 @@ void MapView::keyReleaseEvent(QKeyEvent * event) } } - #if 0 ///////////////////////////////////////////////////////////////////////////// // CMapView printing @@ -1026,7 +1009,6 @@ void MapView::OnPrepareDC(QPainter * dc, CPrintInfo * pInfo) printingPage = 0; } - bool MapView::OnPreparePrinting(CPrintInfo * pInfo) { // Require registration before printing map with more than 10 rooms: @@ -1051,7 +1033,6 @@ bool MapView::OnPreparePrinting(CPrintInfo * pInfo) return DoPreparePrinting(pInfo); } - void MapView::OnBeginPrinting(QPainter * /*pDC*/, CPrintInfo * /*pInfo*/) { // Don't show selection or corners while printing: @@ -1062,7 +1043,6 @@ void MapView::OnBeginPrinting(QPainter * /*pDC*/, CPrintInfo * /*pInfo*/) showCorners = false; } - void MapView::OnEndPrinting(QPainter* /*pDC*/, CPrintInfo* /*pInfo*/) { if (GetDocument()->locked) @@ -1070,7 +1050,6 @@ void MapView::OnEndPrinting(QPainter* /*pDC*/, CPrintInfo* /*pInfo*/) } #endif - // // CMapView miscellaneous // @@ -1089,9 +1068,7 @@ void MapView::addRoom(QPoint & point) return; } - point.rx() -= roomWidth / 2 - gridX / 2; point.rx() -= point.x() % gridX; - point.ry() -= roomHeight / 2 - gridY / 2; point.ry() -= point.y() % gridY; if (point.x() < 0) @@ -1115,7 +1092,6 @@ void MapView::addRoom(QPoint & point) editProperties(epuAddRoom, wasModified); } - // // Make sure we aren't dragging a room off the edge: // @@ -1145,7 +1121,6 @@ void MapView::adjustOffset(QPoint & p) const p.ry() = size.height() - rTmp.bottom(); } - // // Deselect all rooms: // @@ -1187,7 +1162,6 @@ void MapView::clearSelection(bool update/* = true*/) deselectPages(update); } - // // Compute a rectangle enclosing all selected rooms: // @@ -1226,7 +1200,6 @@ void MapView::computeSelectedRect(QRect & r) const } } - // // Deselect a page: // @@ -1270,7 +1243,6 @@ void MapView::deselectPage(int n, bool update/* = true*/) } } - // // Deselect all pages: // @@ -1327,7 +1299,6 @@ void MapView::deselectPages(bool update/* = true*/) selectedOne = -1; } - // // Deselect a room: // @@ -1374,7 +1345,6 @@ void MapView::deselectRoom(RoomNum n, bool update/* = true*/) } } - // // Update the room comments dialog after the selection changes: // @@ -1383,7 +1353,6 @@ void MapView::selectDone() // static_cast(AfxGetApp())->setComment(this, (selectedOne >= 0 ? &(GetDocument()->getRoom(selectedOne)) : NULL)); } - // // Select a page: // @@ -1419,7 +1388,6 @@ void MapView::selectPage(int n, bool update/* = true*/) } } - // // Select a room: // @@ -1461,7 +1429,6 @@ void MapView::selectRoom(RoomNum n, bool update/*= true*/) } } - void MapView::selectOnlyRoom(RoomNum n) { if (selectedOne != n) @@ -1472,7 +1439,6 @@ void MapView::selectOnlyRoom(RoomNum n) } } - // // Make sure that a room is visible: // @@ -1542,7 +1508,6 @@ void MapView::makeRoomVisible(RoomNum n) #endif } - // // Paste a string to the clipboard: // @@ -1582,7 +1547,6 @@ bool MapView::pasteClipboard(const string & text) return true; } - // // Update the selected room's comment from the floating dialog: // @@ -1600,7 +1564,6 @@ void MapView::setRoomNote(const char * comment) } } - int MapView::FindHoveredEdge(void) { for(int i=0; iedge.size(); i++) @@ -1632,7 +1595,6 @@ int MapView::FindHoveredEdge(void) return -1; } - // // Set the step size of the scroll bars: // @@ -1659,7 +1621,6 @@ void MapView::setScrollBars() #endif } - // // Zoom the display: // @@ -1688,7 +1649,6 @@ void MapView::zoomTo(short newZoom) } } - // // Navigation: //--------------------------------------------------------------------------- @@ -1903,7 +1863,6 @@ void MapView::navigate(RoomCorner corner, bool toggleStubs/* = true*/) } } - // // Fill in the edge type from the navigation box: // @@ -1984,7 +1943,6 @@ void MapView::setEdgeType(MapEdge & e) } } - // // Start typing in the navigation bar: // @@ -2007,7 +1965,6 @@ void MapView::setNavText(char c) #endif } - #if 0 void MapView::OnChar(unsigned int c, unsigned int nRepCnt, unsigned int nFlags) { @@ -2020,7 +1977,6 @@ void MapView::OnChar(unsigned int c, unsigned int nRepCnt, unsigned int nFlags) } #endif - // // Parse the text in the navigation bar: // @@ -2095,7 +2051,6 @@ void MapView::getNavText(char & initial, RoomCorner & dir1, char & separator, Ro #endif } - #if 0 // // Handle the Go button in the navigation bar: @@ -2137,7 +2092,6 @@ void MapView::OnNavGo() } } - // // Handle the direction keys on the numeric keypad: // @@ -2178,7 +2132,6 @@ void MapView::OnNavGoDir(unsigned int cmd) MessageBeep(MB_ICONASTERISK); } - // // CMapView message handlers //--------------------------------------------------------------------------- @@ -2193,7 +2146,6 @@ void MapView::OnActivateView(bool bActivate, CView * pActivateView, CView * pDea } #endif - // N.B.: If you click on a corner with no edge coming out of it, it will crash here... !!! FIX !!! [MOSTLY DONE--there's still a way to make it crash with "Add Corner", but I can't remember the specifics...] //void MapView::OnEditAddCorner() void MapView::HandleAddCorner(void) @@ -2213,7 +2165,6 @@ void MapView::HandleAddCorner(void) update(); } - void MapView::HandleAddUnexplored(void) { EdgeVec deletedEdges; @@ -2249,7 +2200,6 @@ void MapView::HandleAddUnexplored(void) update(); } - void MapView::HandleAddLoopBack(void) { EdgeVec deletedEdges; @@ -2285,7 +2235,6 @@ void MapView::HandleAddLoopBack(void) update(); } - void MapView::HandleAddNoExit(void) { EdgeVec deletedEdges; @@ -2321,7 +2270,6 @@ void MapView::HandleAddNoExit(void) update(); } - void MapView::SetEdgeDirection(EdgeType et) { MapEdge e; @@ -2348,31 +2296,26 @@ void MapView::SetEdgeDirection(EdgeType et) update(); } - void MapView::HandleAddUp(void) { SetEdgeDirection(etUp); } - void MapView::HandleAddDown(void) { SetEdgeDirection(etDown); } - void MapView::HandleAddIn(void) { SetEdgeDirection(etIn); } - void MapView::HandleAddOut(void) { SetEdgeDirection(etOut); } - void MapView::SetEdges(int room, int edgeNum, EdgeType eType) { /* @@ -2426,7 +2369,6 @@ One way to make that less awful is to overload the RoomCorner (which, for some r } } - void MapView::ClearEdges(int room, int edgeNum, EdgeType eType) { // Go thru from current room to all connected "corner" rooms @@ -2462,7 +2404,6 @@ void MapView::ClearEdges(int room, int edgeNum, EdgeType eType) } } - void MapView::HandleAddOneWay(void) { MapEdge e; @@ -2477,7 +2418,6 @@ void MapView::HandleAddOneWay(void) update(); } - void MapView::HandleClearOneWay(void) { MapEdge e; @@ -2492,7 +2432,6 @@ void MapView::HandleClearOneWay(void) update(); } - void MapView::HandleAddRestricted(void) { MapEdge e; @@ -2507,7 +2446,6 @@ void MapView::HandleAddRestricted(void) update(); } - void MapView::HandleClearRestricted(void) { MapEdge e; @@ -2522,13 +2460,32 @@ void MapView::HandleClearRestricted(void) update(); } - //void MapView::OnEditAddRoom() void MapView::HandleAddRoom(void) { - addRoom(scrollDragStart); -} +#if 0 + MapDoc * const doc = GetDocument(); + ASSERT_VALID(doc); + + const int p = doc->page.size(); + if (p < maxPages) + { + MapPage page; + page.pos = scrollDragStart; + page.pos.x -= page.pos.x % gridX; + page.pos.y -= page.pos.y % gridY; + doc->setUndoData(new UndoAdd(doc->isDirty, p)); + showPages = true; + doc->addPage(p, page); + clearSelection(); + selectPage(p); + } +#else + QPoint roomPt(scrollDragStart - offset); + addRoom(roomPt); +#endif +} void MapView::HandleMapProperties(void) { @@ -2557,7 +2514,6 @@ void MapView::HandleMapProperties(void) update(); } - //void MapView::OnEditClear() void MapView::HandleDelete(void) { @@ -2565,7 +2521,6 @@ void MapView::HandleDelete(void) update(); } - #if 0 //-------------------------------------------------------------------- void MapView::OnEditAddPage() @@ -2590,7 +2545,6 @@ void MapView::OnEditAddPage() } #endif - // // Input: // removeCorner: (default true) @@ -2661,7 +2615,6 @@ void MapView::deleteSelection(bool removeCorner/* = true*/) } } - #if 0 //-------------------------------------------------------------------- // Cut, Copy & Paste: @@ -2716,14 +2669,12 @@ void MapView::OnEditCopy() } } - void MapView::OnEditCut() { OnEditCopy(); deleteSelection(); } - void MapView::OnEditPaste() { const RoomScrap * scrap = static_cast(AfxGetApp())->getClipboard(); @@ -2750,7 +2701,6 @@ void MapView::OnEditPaste() } } - void MapView::OnEditPaginate() { showPages = true; @@ -2758,7 +2708,6 @@ void MapView::OnEditPaginate() } #endif - // // Handle Edit Properties: // @@ -2768,7 +2717,6 @@ void MapView::HandleRoomProperties(void) editProperties(epuRoomInfo); } - // // Bring up the Properties dialog: // @@ -2933,7 +2881,6 @@ void MapView::editProperties(EditPropUndo undoType, bool wasModified/*= false*/, delete undoRoom; } - #if 0 // // Select all rooms: @@ -2946,7 +2893,6 @@ void MapView::OnEditSelectAll() selectDone(); } - //--------------------------------------------------------------------------- // Select connected rooms: @@ -2979,7 +2925,6 @@ void MapView::OnEditSelectConnected() selectDone(); } - void MapView::OnInitialUpdate() { const MapDoc * doc = GetDocument(); @@ -3005,7 +2950,6 @@ void MapView::OnInitialUpdate() setScrollBars(); // Now fix the scroll bars } - void MapView::OnKeyDown(unsigned int c, unsigned int nRepCnt, unsigned int nFlags) { bool ctrl = (GetKeyState(VK_CONTROL) < 0); @@ -3035,7 +2979,6 @@ void MapView::OnKeyDown(unsigned int c, unsigned int nRepCnt, unsigned int nFlag } #endif - void MapView::mouseDoubleClickEvent(QMouseEvent * event) //void MapView::OnLButtonDblClk(unsigned int nFlags, QPoint point) { @@ -3072,7 +3015,6 @@ void MapView::mouseDoubleClickEvent(QMouseEvent * event) addRoom(point); } - /* N.B.: Handles RButton & MButton too */ void MapView::mousePressEvent(QMouseEvent * event) //void MapView::OnLButtonDown(unsigned int nFlags, QPoint point) @@ -3273,7 +3215,8 @@ Qt::NoModifier, Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifier, etc. { edgeTmp.room1 = room; edgeTmp.end1 = corner; - setEdgeType(edgeTmp); +// This is setting edge types when it shouldn't... So we're commenting this out for now. +// setEdgeType(edgeTmp); } edgeTmp.room2 = 0; @@ -3744,7 +3687,6 @@ void MapView::mouseMoveEvent(QMouseEvent * event) update(); } - //void MapView::OnLButtonUp(unsigned int nFlags, QPoint point) void MapView::mouseReleaseEvent(QMouseEvent * event) { @@ -3985,7 +3927,6 @@ void MapView::mouseReleaseEvent(QMouseEvent * event) update(); } - #if 0 int MapView::OnMouseActivate(CWnd * wnd, unsigned int hitTest, unsigned int message) { @@ -3997,7 +3938,6 @@ int MapView::OnMouseActivate(CWnd * wnd, unsigned int hitTest, unsigned int mess return result; } - bool MapView::OnMouseWheel(unsigned int nFlags, short zDelta, QPoint pt) { if (nFlags == MK_CONTROL) @@ -4009,7 +3949,6 @@ bool MapView::OnMouseWheel(unsigned int nFlags, short zDelta, QPoint pt) return CScrollZoomView::OnMouseWheel(nFlags, zDelta, pt); } - void MapView::OnSize(unsigned int nType, int cx, int cy) { CScrollZoomView::OnSize(nType, cx, cy); @@ -4018,7 +3957,6 @@ void MapView::OnSize(unsigned int nType, int cx, int cy) setScrollBars(); } - void MapView::OnTimer(unsigned int idEvent) { if (idEvent == menuTimer) @@ -4034,7 +3972,6 @@ void MapView::OnTimer(unsigned int idEvent) CScrollZoomView::OnTimer(idEvent); } - // // Update the view after the document changes: // @@ -4107,20 +4044,17 @@ void MapView::OnUpdate(CView * pSender, LPARAM lHint, CObject * pHint) Invalidate(); } - void MapView::OnUpdateEditAddCorner(CCmdUI* pCmdUI) { pCmdUI->Enable(opInProgress == gmoAddCorner); } - void MapView::OnUpdateEditPaste(CCmdUI* pCmdUI) { pCmdUI->Enable((static_cast(AfxGetApp())->getClipboard() != NULL) && !GetDocument()->locked); } - // // Commands which require selected rooms and unlocked document: // @@ -4148,7 +4082,6 @@ void MapView::OnUpdateSelectedUnlocked(CCmdUI * pCmdUI) pCmdUI->Enable(selected && !doc->locked); } - // // Commands which require the document to be unlocked: // @@ -4159,7 +4092,6 @@ void MapView::OnUpdateUnlocked(CCmdUI* pCmdUI) pCmdUI->Enable(!GetDocument()->locked); } - // // Toggle the grid on and off: // @@ -4169,13 +4101,11 @@ void MapView::OnViewGrid() InvalidateRect(NULL); } - void MapView::OnUpdateViewGrid(CCmdUI * pCmdUI) { pCmdUI->SetCheck(showGrid); } - void MapView::OnViewZoom(unsigned int cmd) { ASSERT((cmd == ID_VIEW_ZOOM_IN) || (cmd == ID_VIEW_ZOOM_OUT)); @@ -4186,14 +4116,12 @@ void MapView::OnViewZoom(unsigned int cmd) zoomTo(zoom + 10 - zoom % 10); } - void MapView::OnUpdateViewZoom(CCmdUI * pCmdUI) { pCmdUI->Enable((pCmdUI->m_nID == ID_VIEW_ZOOM_IN) ? (zoom < maxZoom) : (zoom > minZoom)); } - // // Redraw the window: // @@ -4202,7 +4130,6 @@ void MapView::OnWindowRefresh() InvalidateRect(NULL); } - ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // CRepaginateDlg dialog @@ -4222,7 +4149,6 @@ END_MESSAGE_MAP(); ///////////////////////////////////////////////////////////////////////////// // CRepaginateDlg message handlers - bool CRepaginateDlg::OnInitDialog() { CDialog::OnInitDialog(); @@ -4233,10 +4159,8 @@ bool CRepaginateDlg::OnInitDialog() return true; // return TRUE unless you set the focus to a control } - void CRepaginateDlg::OnYes() { EndDialog(IDYES); } #endif -