Click here to Skip to main content
15,920,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Tool tip text Pin
Alexandru Savescu8-Apr-02 22:22
Alexandru Savescu8-Apr-02 22:22 
Generaltemplate members Pin
Jamie Hale8-Apr-02 10:25
Jamie Hale8-Apr-02 10:25 
GeneralRe: template members Pin
Joaquín M López Muñoz8-Apr-02 10:25
Joaquín M López Muñoz8-Apr-02 10:25 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 4:53
Jamie Hale9-Apr-02 4:53 
GeneralRe: template members Pin
Joaquín M López Muñoz9-Apr-02 5:05
Joaquín M López Muñoz9-Apr-02 5:05 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 5:17
Jamie Hale9-Apr-02 5:17 
GeneralRe: template members Pin
Joaquín M López Muñoz9-Apr-02 5:41
Joaquín M López Muñoz9-Apr-02 5:41 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 5:45
Jamie Hale9-Apr-02 5:45 
<small><b>Joaquín M López Muñoz wrote:
</b></small><i>Also, I've seen an unmatched #endif, but I guess it's a only copy&paste error. </i>

As stupid as it would have made me look, you got my hopes up there! Smile | :) But yes, just a copy and paste error.

What follows is one of the offending .cpp files (with the corresponding header file as well). I'm sure the only thing you need to look at it the include order at the top of the .cpp.

Flaw.hpp just includes a bunch of constants carried over from the previous version.

J

/* BFrame.h
*
*
*/

#ifndef _BFRAME_H_
#define _BFRAME_H_

#include "Flaw.hpp"

class CFLAWDoc;

class CBFrame
{

private:

// Data is essentially a 3D graph
// ------------------------------
// so list the dimensions

cbDIMENSIONS size;

short frame_number; // current frame (starts from 0)
short line_number; // current line within current frame
LONG channel_offset; // beginning of B-Scan Channel
POSL current; // current position corresponding to
// data (raw axial)
public:
CFile f; // File class
void SetDoc (CFLAWDoc *p);
CFLAWDoc *pDoc; // ptr to the Document Class
DWORD Axial ();
short WavePoints ();
short FrameNumber ();
short LineNumber ();
short RotaryPoints ();
short AxialPoints ();
void SetAxialPoints (short ap);
void SetChannelOffset (long co);
CBFrame (CString FileName, // Constructor for reading B-Scan
LONG ChannelOffset);
virtual ~CBFrame();
cbRETURN_CODE Read (short *frame, short *line, BYTE * data);
cbRETURN_CODE ReadFramePosition (short frame, POSL *pos);
BYTE Seek (DWORD axial); // Locate frame associated with
// specified axial position (raw value)
// in units of 0.00807
BYTE Seek (short frame, short line, short point = 0);
BYTE Seek (short frame, POSL *pos);
BYTE Seek (short frame);
BYTE AdvanceFrame (BYTE inc);
};

#endif // !defined(AFX_BFRAME_H__76544D71_721F_11D4_88BF_006008662998__INCLUDED_)


// BFrame.cpp: implementation of the CBFrame class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include "BFrame.h"
#include "FlawDoc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

// Constructor for Circumferential B-scan frame - read
// ============================================
// file is expected to be already opened, as specified by FileName
// and offset to beginning of data specified by ChannelOffset

CBFrame::CBFrame (CString FileName, long ChannelOffset)

{
channel_offset = ChannelOffset;
CFileException e;

if (!f.Open (FileName,
CFile::modeRead |
CFile::shareDenyWrite |
CFile::typeBinary,
&e))
{
AfxMessageBox ("Error: Unable to open File",MB_OK, NULL);
}

long seek = f.Seek (ChannelOffset, CFile::begin);
f.Read (&size.WavePoints, sizeof (size.WavePoints));
f.Read (&size.RotaryPoints, sizeof (size.RotaryPoints));
f.Read (&size.AxialPoints, sizeof (size.AxialPoints));

frame_number = 0;
line_number = 0;
}

CBFrame::~CBFrame()
{

}

// Functions to provide access to private data variables

short CBFrame::WavePoints ()
{
return size.WavePoints;
}

short CBFrame::FrameNumber ()
{
return frame_number;
}

short CBFrame::LineNumber ()
{
return line_number;
}

short CBFrame::RotaryPoints ()
{
return size.RotaryPoints;
}

DWORD CBFrame::Axial ()
{
return current.axial;
}

short CBFrame::AxialPoints ()
{
return size.AxialPoints;
}

// Functions to alter private data variables

void CBFrame::SetChannelOffset (long co)
{
channel_offset = co;
}

void CBFrame::SetAxialPoints (short ap)
{
size.AxialPoints = ap;
}

// Seek a particular frame based on axial value
// ============================================
// axial is raw value in units of flAXIAL_MM_PER_BIT

BYTE CBFrame::Seek (DWORD axial)

{
long offset;

if ((axial >= (DWORD) pDoc->GetFirstPosition()->GetAxial()
) &&
(axial <= (DWORD) pDoc->GetLastPosition()->GetAxial()
)
)
{

// Remember
// --------
// that the axial increment is rounded up to the nearest
// measurable axial value

WORD inc;

inc = pDoc->GetAxialIncrement();
inc += (1 << flAXIAL_BITS_DROPPED) - 1;
inc >>= flAXIAL_BITS_DROPPED;

// June 1, 1993
// ------------
// remove roundup with (inc >> 1). Gives more accurate mapping

frame_number = (short)( (axial -
(DWORD) pDoc->GetFirstPosition()->GetAxial())/inc);

// Ensure frame number within range
// --------------------------------

if (frame_number < 0)
{
frame_number = 0;
}
if (frame_number >= size.AxialPoints)
{
frame_number = size.AxialPoints - 1;
}

offset = channel_offset + 6 /* sizeof (cbDIMENSIONS) */;
offset += frame_number * ((long) size.WavePoints * size.RotaryPoints +
6 /* sizeof (POSL) */);

f.Seek (offset, CFile::begin);

return TRUE;
}
return FALSE;
}

// Seek the beginning of a particular frame
// ========================================
// and return the position information associated with that frame

BYTE CBFrame::Seek (short frame, POSL *pos)

{
long offset;

// Make sure parameters are legal
// ------------------------------

if (!(frame >= 0 && frame < size.AxialPoints))
{
return (FALSE);
}

offset = channel_offset + 6 /* sizeof (cbDIMENSIONS) */;

offset += frame * ((long) size.WavePoints * size.RotaryPoints +
6 /* sizeof (POSL) */);

f.Seek (offset, CFile::begin);

f.Read (pos, 6 /* sizeof (POSL) */);

frame_number = frame;
line_number = 0;
return (TRUE);
}

// Seek the beginning of a particular frame
// ========================================
// Recall that the first record of each frame is the position associated
// with that frame

BYTE CBFrame::Seek (short frame)

{
long offset;

/* Make sure parameters are legal
------------------------------ */

if (!(frame >= 0 && frame < size.AxialPoints))
{
return (FALSE);
}

offset = channel_offset + 6 /* sizeof (cbDIMENSIONS) */;

offset += frame * ((long) size.WavePoints * size.RotaryPoints +
6 /* sizeof (POSL) */);

f.Seek (offset, CFile::begin);

frame_number = frame;
line_number = 0;
return (TRUE);
}

// Seek particular frame and line, and point in line
// =================================================

byte CBFrame::Seek (short frame, short line, short point)

{
long offset;

/* Make sure parameters are legal
------------------------------ */

if (!(frame >= 0 && frame < size.AxialPoints))
{
return (FALSE);
}

if (!(line >= 0 && line < size.RotaryPoints))
{
return (FALSE);
}

offset = channel_offset + 6 /* sizeof (cbDIMENSIONS) */;

offset += frame * ((long) size.WavePoints * size.RotaryPoints +
6 /* sizeof (POSL) */) + 6 /* sizeof (POSL) */;
offset += (long) line * size.WavePoints + point;

f.Seek (offset, CFile::begin);

frame_number = frame;
line_number = line;
return (TRUE);
}


// Read next line
// ==============
// Returns pointer to buffer if successful
// Returns NULL at end-of-frame, and end-of-file.
// end-of-frame can be distinquished by end-of-file by examining
// frame and line. If end-of-file, frame = line = -1.
// If end-of-frame, frame = next frame value, line = 0.

cbRETURN_CODE CBFrame::Read (short *frame, short *line, BYTE * data)

{

/* Special case if line_number = 0
-------------------------------
read in the position. This may be optionally displayed by the system */

if (line_number == 0)
{
Seek (frame_number);

if (f.Read (&current, 6 /* sizeof (POSL) */) != 6 /* sizeof (POSL) */)
{
return cbUNKNOWN;
}
}

/* Is there another line to read in present frame?
----------------------------------------------- */

if (line_number < size.RotaryPoints)
{
*line = line_number++;
*frame = frame_number;

if (f.Read (data, size.WavePoints) != (unsigned) size.WavePoints)
{
return cbUNKNOWN;
}

return (cbOK);
}

/* Is there another frame to read?
------------------------------- */

if (frame_number < size.AxialPoints - 1)
{
*frame = ++frame_number;
*line = line_number = 0;

return cbEND_OF_FRAME;
}

/* End of file
----------- */

*frame = frame_number = -1;
*line = line_number = -1;

return cbEND_OF_DATA;
}

// This advances the frame number if possible. The parameter is
// used to indicate whether to increment or decrement the
// frame number.

BYTE CBFrame::AdvanceFrame (BYTE inc)
{

/* Special case
------------
line_number should be 0, but if not, advance frame_number */

if (line_number != 0)
{
if (frame_number < size.AxialPoints - 1)
{
++frame_number;
}
}

/* Is there another frame to read?
-------------------------------
Remember that frame_number is set at the next frame, not the
current frame */

if (inc)
{
if (frame_number < size.AxialPoints)
{
return (TRUE);
}
return (FALSE);
}

// else
{
if (frame_number > 1)
{
frame_number -= 2;
return (TRUE);
}
return (FALSE);
}
}

// This function retrieves the recorded position information
// associated with the axial slice in the given frame.

cbRETURN_CODE CBFrame::ReadFramePosition (short frame, POSL *pos)

{

if (!Seek (frame))
{
return cbUNKNOWN;
}

if (f.Read (pos, 6 /* sizeof (POSL) */))
{
return cbUNKNOWN;
}

return cbOK;
}

// Assign pointer to the Document Class

void CBFrame::SetDoc(CFLAWDoc *p)
{
pDoc = p;
}

J

GeneralRe: template members Pin
Joaquín M López Muñoz9-Apr-02 6:12
Joaquín M López Muñoz9-Apr-02 6:12 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 6:38
Jamie Hale9-Apr-02 6:38 
GeneralRe: template members Pin
Joaquín M López Muñoz9-Apr-02 6:15
Joaquín M López Muñoz9-Apr-02 6:15 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 6:39
Jamie Hale9-Apr-02 6:39 
GeneralRe: template members Pin
Joaquín M López Muñoz9-Apr-02 7:07
Joaquín M López Muñoz9-Apr-02 7:07 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 7:34
Jamie Hale9-Apr-02 7:34 
GeneralRe: template members Pin
Joaquín M López Muñoz9-Apr-02 7:44
Joaquín M López Muñoz9-Apr-02 7:44 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 6:18
Jamie Hale9-Apr-02 6:18 
GeneralRe: template members Pin
CodeGuy9-Apr-02 6:28
CodeGuy9-Apr-02 6:28 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 6:44
Jamie Hale9-Apr-02 6:44 
GeneralRe: template members Pin
Christian Graus8-Apr-02 10:26
protectorChristian Graus8-Apr-02 10:26 
GeneralRe: template members Pin
Tim Smith8-Apr-02 10:42
Tim Smith8-Apr-02 10:42 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 4:57
Jamie Hale9-Apr-02 4:57 
GeneralRe: template members Pin
Jamie Hale9-Apr-02 4:55
Jamie Hale9-Apr-02 4:55 
GeneralSaving Icons Pin
Shog98-Apr-02 9:00
sitebuilderShog98-Apr-02 9:00 
GeneralRe: Saving Icons Pin
Roman Nurik8-Apr-02 9:57
Roman Nurik8-Apr-02 9:57 
GeneralRe: Saving Icons Pin
Shog98-Apr-02 10:23
sitebuilderShog98-Apr-02 10:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.