Skip to content

Commit

Permalink
[#40] Track Map: General improvements and bugfixes (Part 1: Added zoo…
Browse files Browse the repository at this point in the history
…ming in and out of sectors)
  • Loading branch information
tomas-nestorovic committed Nov 8, 2019
1 parent bcd945b commit a2e60dd
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Main/res/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@
#define ID_NAVIGATE_PREVIOUSTRACK 40253
#define ID_NAVIGATE_SECTOR 40254
#define ID_BOOKMARK_DELETEALL 40257
#define ID_ZOOM_OUT 40267
#define ID_ZOOM_IN 40268
#define ID_Y 58113
#define ID_W 58114
#define ID_H 58115
Expand All @@ -230,7 +232,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 214
#define _APS_NEXT_COMMAND_VALUE 40267
#define _APS_NEXT_COMMAND_VALUE 40269
#define _APS_NEXT_CONTROL_VALUE 1181
#define _APS_NEXT_SYMED_VALUE 103
#endif
Expand Down
3 changes: 3 additions & 0 deletions Main/res/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ BEGIN
MENUITEM "Sector data", ID_TRACKMAP_DATA
MENUITEM "Bad sector data (if any)", ID_TRACKMAP_BAD_DATA
MENUITEM SEPARATOR
MENUITEM "Zoom in", ID_ZOOM_IN
MENUITEM "Zoom out", ID_ZOOM_OUT
MENUITEM SEPARATOR
MENUITEM "Numbering", ID_TRACKMAP_NUMBERING
POPUP "Helpers"
BEGIN
Expand Down
Binary file modified Main/res/trackMap.bmp
Binary file not shown.
41 changes: 32 additions & 9 deletions Main/src/ViewTrackMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
CTrackMapView::CTrackMapView(PDos _dos)
// ctor
: tab( IDR_TRACKMAP, IDR_TRACKMAP, ID_CYLINDER, _dos, this )
, displayType(TDisplayType::STATUS) , showSectorNumbers(false) , highlightBadSectors(false) , iScrollY(0) , scanner(this) {
, displayType(TDisplayType::STATUS) , showSectorNumbers(false) , highlightBadSectors(false) , iScrollY(0) , scanner(this)
, zoomLengthFactor(3) {
::ZeroMemory( rainbowBrushes, sizeof(rainbowBrushes) );
}

Expand All @@ -40,6 +41,10 @@
ON_UPDATE_COMMAND_UI_RANGE(ID_TRACKMAP_STATUS,ID_TRACKMAP_BAD_DATA,__changeDisplayType_updateUI__)
ON_COMMAND(ID_TRACKMAP_NUMBERING,__toggleSectorNumbering__)
ON_UPDATE_COMMAND_UI(ID_TRACKMAP_NUMBERING,__toggleSectorNumbering_updateUI__)
ON_COMMAND(ID_ZOOM_IN,__zoomIn__)
ON_UPDATE_COMMAND_UI(ID_ZOOM_IN,__zoomIn_updateUI__)
ON_COMMAND(ID_ZOOM_OUT,__zoomOut__)
ON_UPDATE_COMMAND_UI(ID_ZOOM_OUT,__zoomOut_updateUI__)
ON_COMMAND(ID_TRACKMAP_STATISTICS,__showDiskStatistics__)
END_MESSAGE_MAP()

Expand Down Expand Up @@ -142,8 +147,6 @@
Utils::ScaleLogicalUnit(*pDC);
}

#define SECTOR_LENGTH_FACTOR 3

static const int Tabs[]={ VIEW_PADDING, VIEW_PADDING+60, SECTOR1_X };

afx_msg LRESULT CTrackMapView::__drawTrack__(WPARAM trackNumber,LPARAM pTrackInfo){
Expand Down Expand Up @@ -176,7 +179,7 @@
CDos::TSectorStatus statuses[(TSector)-1],*ps=statuses;
DOS->GetSectorStatuses( rti.cylinder, rti.head, nSectors, pId, statuses );
for( ; nSectors--; r.left=r.right+=SECTOR_MARGIN ){
r.right+=1+(*pLength++>>SECTOR_LENGTH_FACTOR); // "1+" = to correctly display a zero-length Sector
r.right+=1+(*pLength++>>zoomLengthFactor); // "1+" = to correctly display a zero-length Sector
const CBrush brush(*ps++);
const HGDIOBJ hBrush0=::SelectObject(dc,brush);
dc.Rectangle(&r);
Expand All @@ -187,12 +190,12 @@
}else
// drawing Sector data
for( const PCSectorData *pData=rti.bufferSectorData; nSectors--; r.left=r.right+=SECTOR_MARGIN ){
const WORD w=*pLength++>>SECTOR_LENGTH_FACTOR;
const WORD w=*pLength++>>zoomLengthFactor;
if (PCBYTE sample=(PCBYTE)*pData++){
// Sector found - drawing its data
RECT rcSample=r;
rcSample.right=rcSample.left+2;
for( WORD n=w; n--; sample+=(1<<SECTOR_LENGTH_FACTOR),rcSample.left++,rcSample.right++ )
for( WORD n=w; n--; sample+=(1<<zoomLengthFactor),rcSample.left++,rcSample.right++ )
::FillRect( dc, &rcSample, rainbowBrushes[*sample] );
r.right+=1+w; // "1+" = to correctly display a zero-length Sector
::FrameRect( dc, &r, Utils::CRideBrush::Black );
Expand Down Expand Up @@ -227,10 +230,10 @@
PCSectorId pRefId=&item->chs.sectorId, bufferId=rti.bufferId;
PCWORD pw=rti.bufferLength;
r.left=SECTOR1_X;
for( TSector nSectors=rti.nSectors; nSectors--; r.left+=(*pw++>>SECTOR_LENGTH_FACTOR)+SECTOR_MARGIN )
for( TSector nSectors=rti.nSectors; nSectors--; r.left+=(*pw++>>zoomLengthFactor)+SECTOR_MARGIN )
if (*pRefId==*bufferId++)
break;
r.right=r.left+1+(*pw>>SECTOR_LENGTH_FACTOR); // "1+" = to correctly display a zero-length Sector
r.right=r.left+1+(*pw>>zoomLengthFactor); // "1+" = to correctly display a zero-length Sector
dc.Rectangle(&r);
}
}
Expand Down Expand Up @@ -324,7 +327,7 @@
CDos::TSectorStatus statuses[(TSector)-1],*pStatus=statuses;
DOS->GetSectorStatuses( d.quot, d.rem, nSectors, bufferId, statuses );
for( int xL=0,xR=0; nSectors--; pStatus++,pId++ ){
xR+=*pLength++>>SECTOR_LENGTH_FACTOR;
xR+=*pLength++>>zoomLengthFactor;
if (point.x>=xL && point.x<=xR){
// cursor over a Sector
TCHAR buf[40],tmp[30];
Expand Down Expand Up @@ -379,6 +382,26 @@
pCmdUI->Enable(displayType==TDisplayType::STATUS);
}

afx_msg void CTrackMapView::__zoomOut__(){
// zooms out the view
zoomLengthFactor++;
Invalidate(TRUE);
}
afx_msg void CTrackMapView::__zoomOut_updateUI__(CCmdUI *pCmdUI){
// projects possibility to even more zoom out the view
pCmdUI->Enable( zoomLengthFactor<8 );
}

afx_msg void CTrackMapView::__zoomIn__(){
// zooms in the view
zoomLengthFactor--;
Invalidate(TRUE);
}
afx_msg void CTrackMapView::__zoomIn_updateUI__(CCmdUI *pCmdUI){
// projects possibility to even more zoom in the view
pCmdUI->Enable( zoomLengthFactor>0 );
}


struct TStatisticParams sealed{
const CDos *const dos;
Expand Down
5 changes: 5 additions & 0 deletions Main/src/ViewTrackMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
TTrackScanner(const CTrackMapView *pvtm); // ctor
} scanner;
bool showSectorNumbers,highlightBadSectors;
BYTE zoomLengthFactor;

void OnUpdate(CView *pSender,LPARAM lHint,CObject *pHint) override;
BOOL OnScroll(UINT nScrollCode,UINT nPos,BOOL bDoScroll=TRUE) override;
Expand All @@ -41,6 +42,10 @@
afx_msg void __changeDisplayType_updateUI__(CCmdUI *pCmdUI);
afx_msg void __toggleSectorNumbering__();
afx_msg void __toggleSectorNumbering_updateUI__(CCmdUI *pCmdUI);
afx_msg void __zoomOut__();
afx_msg void __zoomOut_updateUI__(CCmdUI *pCmdUI);
afx_msg void __zoomIn__();
afx_msg void __zoomIn_updateUI__(CCmdUI *pCmdUI);
afx_msg void __showDiskStatistics__();
public:
const CMainWindow::CTdiView::TTab tab;
Expand Down

0 comments on commit a2e60dd

Please sign in to comment.