This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

BIN
meshwrp/944.ICO Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
meshwrp/Debug/convex.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/factor.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/framedlg.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/image.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/imageview.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/main.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/mainfrm.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/mesh.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/meshwrp.exe Normal file

Binary file not shown.

BIN
meshwrp/Debug/meshwrp.exp Normal file

Binary file not shown.

BIN
meshwrp/Debug/meshwrp.ilk Normal file

Binary file not shown.

BIN
meshwrp/Debug/meshwrp.lib Normal file

Binary file not shown.

BIN
meshwrp/Debug/meshwrp.pdb Normal file

Binary file not shown.

BIN
meshwrp/Debug/meshwrp.res Normal file

Binary file not shown.

BIN
meshwrp/Debug/polypnt.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/segment.obj Normal file

Binary file not shown.

BIN
meshwrp/Debug/vc60.idb Normal file

Binary file not shown.

BIN
meshwrp/Debug/vc60.pdb Normal file

Binary file not shown.

BIN
meshwrp/PAINT.ICO Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

BIN
meshwrp/arrowd.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/arrowl.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/arrowr.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/arrowu.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/bload.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/bsave.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/clip.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

54
meshwrp/convex.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include <meshwrp/main.hpp>
#include <meshwrp/convex.hpp>
#include <meshwrp/image.hpp>
#include <common/math.hpp>
#include <common/guiwnd.hpp>
Convex::Convex()
: mWidth(0), mHeight(0), mxHalf(0), myHalf(0)
{
}
Convex::~Convex()
{
}
Image Convex::performConvex(Image &srcImage,GUIWindow &window)
{
RGB888 rgb888;
Image dstImage;
POINT tempPoint;
double scaleFactor;
double tempFactor;
mWidth=srcImage.width();
mHeight=srcImage.height();
mxHalf=mWidth/2;
myHalf=mHeight/2;
dstImage.newImage(mWidth,mHeight,window);
for(int y=0;y<mHeight;y++)
{
for(int x=0;x<mWidth;x++)
{
setPoint(x,y,tempPoint);
cartesianPoint(tempPoint);
tempFactor=::sqrt(((LONG)tempPoint.x*(LONG)tempPoint.x)+((LONG)tempPoint.y*(LONG)tempPoint.y));
tempFactor*=Math::piOver180();
if(tempFactor)scaleFactor=(::tan(::atan(tempFactor)/2.00))/tempFactor;
else scaleFactor=0.00;
scaleFactor*=2;
tempFactor=scaleFactor*(double)tempPoint.x;
tempFactor+=(tempFactor<0?-.5:.5);
tempPoint.x=tempFactor;
tempFactor=scaleFactor*(double)tempPoint.y;
tempFactor+=(tempFactor<0?-.5:.5);
tempPoint.y=tempFactor;
imagePoint(tempPoint);
if(tempPoint.x>=mWidth)continue;
if(tempPoint.y>=mHeight)continue;
srcImage.getAt(y,x,rgb888);
dstImage.setAt(tempPoint.y,tempPoint.x,rgb888);
}
}
return dstImage;
}

47
meshwrp/convex.hpp Normal file
View File

@@ -0,0 +1,47 @@
#ifndef _MESHWRP_CONVEX_HPP_
#define _MESHWRP_CONVEX_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
class Image;
class GUIWindow;
class Convex
{
public:
Convex(void);
virtual ~Convex(void);
Image performConvex(Image &srcImage,GUIWindow &window);
private:
void cartesianPoint(POINT &imagePoint)const;
void imagePoint(POINT &cartesianPoint)const;
void setPoint(int x,int y,POINT &somePoint)const;
unsigned long mxHalf;
unsigned long myHalf;
unsigned long mWidth;
unsigned long mHeight;
};
inline
void Convex::cartesianPoint(POINT &imagePoint)const
{
imagePoint.x-=mxHalf;
imagePoint.y=(mHeight-1)-(myHalf+imagePoint.y);
}
inline
void Convex::imagePoint(POINT &cartesianPoint)const
{
cartesianPoint.x+=mxHalf;
cartesianPoint.y=(mHeight-1)-(myHalf+cartesianPoint.y);
}
inline
void Convex::setPoint(int x,int y,POINT &point)const
{
point.x=x;
point.y=y;
}
#endif

BIN
meshwrp/cut.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

BIN
meshwrp/eject.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

169
meshwrp/factor.cpp Normal file
View File

@@ -0,0 +1,169 @@
#include <meshwrp/factor.hpp>
#include <meshwrp/resource.hpp>
Factor::Factor(GUIWindow &parent,const String &strCaption)
: mhParent(parent), mWidthFactor(0.00), mWidthIncremental(0.00),
mWidthOperation(None), mHeightFactor(0.00), mHeightIncremental(0.00),
mHeightOperation(None), mhInstance(parent.processInstance())
{
mInitHandler.setCallback(this,&Factor::initHandler);
mCommandHandler.setCallback(this,&Factor::commandHandler);
insertHandler(VectorHandler::CommandHandler,&mCommandHandler);
insertHandler(VectorHandler::InitDialogHandler,&mInitHandler);
mCaption=strCaption;
}
Factor::~Factor()
{
removeHandler(VectorHandler::CommandHandler,&mCommandHandler);
removeHandler(VectorHandler::InitDialogHandler,&mInitHandler);
}
bool Factor::showFactor(double &widthFactor,double &heightFactor,double &widthIncremental,Operation &widthOperation,double &heightIncremental,Operation &heightOperation)
{
bool returnCode;
mFactorType=Incremental;
returnCode=::DialogBoxParam(mhInstance,(LPSTR)"Factor",mhParent,(DLGPROC)DWindow::DlgProc,(LONG)((DWindow*)this));
if(!returnCode)return false;
widthFactor=mWidthFactor;
widthIncremental=mWidthIncremental;
widthOperation=mWidthOperation;
heightFactor=mHeightFactor;
heightIncremental=mHeightIncremental;
heightOperation=mHeightOperation;
return true;
}
bool Factor::showFactor(double &widthFactor,double &heightFactor)
{
bool returnCode;
mFactorType=NonIncremental;
returnCode=::DialogBoxParam(mhInstance,(LPSTR)"Factor",mhParent,(DLGPROC)DWindow::DlgProc,(LONG)((DWindow*)this));
if(!returnCode)return false;
widthFactor=mWidthFactor;
heightFactor=mHeightFactor;
return true;
}
void Factor::initializeStrings(void)
{
mWidthStringIndex=0;
mHeightStringIndex=0;
mWidthStrings.insert(&String("+="));
mWidthStrings.insert(&String("-="));
mWidthStrings.insert(&String("\\="));
mWidthStrings.insert(&String("*="));
mHeightStrings.insert(&mWidthStrings[0]);
mHeightStrings.insert(&mWidthStrings[1]);
mHeightStrings.insert(&mWidthStrings[2]);
mHeightStrings.insert(&mWidthStrings[3]);
}
void Factor::currentOperation(WORD stringIndex,Operation &operation)const
{
switch(stringIndex)
{
case 0 :
operation=Add;
break;
case 1 :
operation=Subtract;
break;
case 2 :
operation=Divide;
break;
case 3 :
operation=Multiply;
break;
}
}
CallbackData::ReturnType Factor::initHandler(CallbackData &callbackData)
{
mWidthStrings.remove();
mHeightStrings.remove();
if(Incremental==mFactorType)
{
Rect cRect;
windowRect(cRect);
moveWindow(Rect(cRect.left(),cRect.top(),407,148),true);
initializeStrings();
currentOperation(mWidthStringIndex,mWidthOperation);
currentOperation(mHeightStringIndex,mHeightOperation);
setText(FACTOR_WOPSTRING,mWidthStrings[mWidthStringIndex]);
setText(FACTOR_HOPSTRING,mHeightStrings[mHeightStringIndex]);
}
setCaption(mCaption);
return true;
}
CallbackData::ReturnType Factor::commandHandler(CallbackData &callbackData)
{
switch(callbackData.wmCommandID())
{
case FACTOR_WIDTHOP :
handleWidth(callbackData);
break;
case FACTOR_HEIGHTOP :
handleHeight(callbackData);
break;
case IDOK :
handleOk(callbackData);
break;
case IDCANCEL :
handleCancel();
break;
}
return true;
}
void Factor::handleWidth(CallbackData &callbackData)
{
LRESULT checkState;
if(!(BN_CLICKED==HIWORD(callbackData.lParam())))return;
if(!mWidthStrings.size())return;
if(++mWidthStringIndex>=mWidthStrings.size())mWidthStringIndex=0;
checkState=sendMessage(FACTOR_WIDTHOP,BM_GETCHECK,0,0L);
sendMessage(FACTOR_WIDTHOP,BM_SETCHECK,!checkState,0L);
setText(FACTOR_WOPSTRING,mWidthStrings[mWidthStringIndex]);
sendMessage(FACTOR_WIDTHOP,BM_SETCHECK,!(!checkState),0L);
currentOperation(mWidthStringIndex,mWidthOperation);
}
void Factor::handleHeight(CallbackData &callbackData)
{
LRESULT checkState;
if(!(BN_CLICKED==HIWORD(callbackData.lParam())))return;
if(!mHeightStrings.size())return;
if(++mHeightStringIndex>=mHeightStrings.size())mHeightStringIndex=0;
checkState=sendMessage(FACTOR_HEIGHTOP,BM_GETCHECK,0,0L);
sendMessage(FACTOR_HEIGHTOP,BM_SETCHECK,!checkState,0L);
setText(FACTOR_HOPSTRING,mHeightStrings[mHeightStringIndex]);
sendMessage(FACTOR_HEIGHTOP,BM_SETCHECK,!(!checkState),0L);
currentOperation(mHeightStringIndex,mHeightOperation);
}
void Factor::handleOk(CallbackData &callackData)
{
String itemText;
getText(FACTOR_WIDTH,itemText);
mWidthFactor=itemText.toDouble();
getText(FACTOR_HEIGHT,itemText);
mHeightFactor=itemText.toDouble();
getText(FACTOR_WIDTHINCR,itemText);
mWidthIncremental=itemText.toDouble();
getText(FACTOR_HEIGHTINCR,itemText);
mHeightIncremental=itemText.toDouble();
endDialog(true);
}
void Factor::handleCancel()
{
endDialog(false);
}

55
meshwrp/factor.hpp Normal file
View File

@@ -0,0 +1,55 @@
#ifndef _MESHWRP_FACTOR_HPP_
#define _MESHWRP_FACTOR_HPP_
#ifndef _COMMON_DWINDOW_HPP_
#include <common/dwindow.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
class Factor : public DWindow
{
public:
enum Type{Incremental,NonIncremental};
enum Operation{Add,Subtract,Multiply,Divide,None};
Factor(GUIWindow &parent,const String &strCaption);
virtual ~Factor();
bool showFactor(double &widthFactor,double &heightFactor);
bool showFactor(double &widthFactor,double &heightFactor,
double &widthIncremental,Operation &widthOperation,
double &heightIncremental, Operation &heightOperation);
private:
CallbackData::ReturnType initHandler(CallbackData &callbackData);
CallbackData::ReturnType commandHandler(CallbackData &callbackData);
void handleWidth(CallbackData &callackData);
void handleHeight(CallbackData &callbackData);
void handleOk(CallbackData &callbackData);
void handleCancel(void);
// virtual int DlgProc(UINT message,WPARAM wParam,LPARAM lParam);
void initializeStrings(void);
void currentOperation(WORD stringIndex,Operation &operation)const;
HWND mhParent;
HINSTANCE mhInstance;
String mCaption;
Callback<Factor> mInitHandler;
Callback<Factor> mCommandHandler;
// char mCaption[MaxCaption];
double mWidthFactor;
double mWidthIncremental;
Operation mWidthOperation;
double mHeightFactor;
double mHeightIncremental;
Operation mHeightOperation;
Type mFactorType;
Block<String> mWidthStrings;
Block<String> mHeightStrings;
WORD mWidthStringIndex;
WORD mHeightStringIndex;
};
#endif

BIN
meshwrp/filehelp.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
meshwrp/filenew.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
meshwrp/fileopen.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
meshwrp/filesave.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
meshwrp/frame.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

75
meshwrp/framedlg.cpp Normal file
View File

@@ -0,0 +1,75 @@
#include <meshwrp/framedlg.hpp>
#include <meshwrp/resource.hpp>
FrameDialog::FrameDialog(const GUIWindow &parentWindow)
: mhParent(parentWindow)
{
mInitDialogHandler.setCallback(this,&FrameDialog::initDialogHandler);
mCommandHandler.setCallback(this,&FrameDialog::commandHandler);
insertHandler(VectorHandler::CommandHandler,&mCommandHandler);
insertHandler(VectorHandler::InitDialogHandler,&mInitDialogHandler);
}
FrameDialog::FrameDialog(const FrameDialog &someFrameDialog)
: mhParent(someFrameDialog.mhParent)
{ // no implementation
mInitDialogHandler.setCallback(this,&FrameDialog::initDialogHandler);
mCommandHandler.setCallback(this,&FrameDialog::commandHandler);
}
FrameDialog::~FrameDialog()
{
removeHandler(VectorHandler::CommandHandler,&mCommandHandler);
removeHandler(VectorHandler::InitDialogHandler,&mInitDialogHandler);
}
FrameDialog &FrameDialog::operator=(const FrameDialog &/*someEntryDialog*/)
{ // no implementation
return *this;
}
WORD FrameDialog::perform(DWORD &meshFrames)
{
mMeshFrames=meshFrames;
WORD resultCode(::DialogBoxParam(processInstance(),(LPSTR)"Frame",mhParent,(DLGPROC)DWindow::DlgProc,(LONG)((DWindow*)this)));
if(resultCode)meshFrames=mMeshFrames;
return resultCode;
}
CallbackData::ReturnType FrameDialog::initDialogHandler(CallbackData &/*someCallbackData*/)
{
setFrameCount(mMeshFrames);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType FrameDialog::commandHandler(CallbackData &someCallbackData)
{
switch(someCallbackData.wmCommandID())
{
case IDOK :
mMeshFrames=getFrameCount();
endDialog(TRUE);
break;
case IDCANCEL :
endDialog(FALSE);
break;
}
return (CallbackData::ReturnType)FALSE;
}
DWORD FrameDialog::getFrameCount(void)
{
String strControlText;
getText(FRAME_FRAMES,strControlText);
return strControlText.toInt();
}
void FrameDialog::setFrameCount(DWORD frameCount)
{
String strControlText;
strControlText.fromInt(frameCount);
setText(FRAME_FRAMES,strControlText);
}

32
meshwrp/framedlg.hpp Normal file
View File

@@ -0,0 +1,32 @@
#ifndef _MESHWRP_FRAMEDLG_HPP_
#define _MESHWRP_FRAMEDLG_HPP_
#ifndef _COMMON_DWINDOW_HPP_
#include <common/dwindow.hpp>
#endif
#ifndef _COMMON_WINDOW_HPP_
#include <common/window.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
class FrameDialog : private DWindow
{
public:
FrameDialog(const GUIWindow &parentWindow);
virtual ~FrameDialog();
WORD perform(DWORD &meshFrames);
private:
FrameDialog(const FrameDialog &someFrameDialog);
FrameDialog &operator=(const FrameDialog &someFrameDialog);
CallbackData::ReturnType initDialogHandler(CallbackData &someCallbackData);
CallbackData::ReturnType commandHandler(CallbackData &someCallbackData);
DWORD getFrameCount(void);
void setFrameCount(DWORD frameCount);
Callback<FrameDialog> mInitDialogHandler;
Callback<FrameDialog> mCommandHandler;
DWORD mMeshFrames;
HWND mhParent;
};
#endif

112
meshwrp/image.cpp Normal file
View File

@@ -0,0 +1,112 @@
#include <meshwrp/image.hpp>
#include <common/crsctrl.hpp>
#include <gif/gifbmp.hpp>
Image::Image()
{
}
Image::~Image()
{
}
bool Image::open(String strPathFileName,GUIWindow &window)
{
CursorControl cursorControl;
PureDevice pureDevice;
bool returnCode=false;
if(strPathFileName.isNull())return false;
strPathFileName.lower();
pureDevice=window;
cursorControl.waitCursor(true);
if(0!=strPathFileName.strstr(".gif"))returnCode=handleOpenGIF(strPathFileName,pureDevice);
else if(0!=strPathFileName.strstr(".jpg"))returnCode=handleOpenJPG(strPathFileName,pureDevice);
else if(0!=strPathFileName.strstr(".bmp"))returnCode=handleOpenBMP(strPathFileName,pureDevice);
cursorControl.waitCursor(false);
return returnCode;
}
bool Image::newImage(LONG width,LONG height,GUIWindow &window)
{
PureDevice pureDevice;
pureDevice=window;
create(width,height,pureDevice);
if(!isOkay())return false;
for(int row=0;row<DIB24::height();row++)
{
for(int col=0;col<DIB24::width();col++)
{
setAt(row,col,RGB888(0,0,0));
}
}
return true;
}
bool Image::handleOpenGIF(const String &strPathFileName,PureDevice &pureDevice)
{
GIFBitmap gifBitmap;
if(!gifBitmap.open(strPathFileName))return false;
create(gifBitmap.width(),-gifBitmap.height(),pureDevice);
PurePalette palette(gifBitmap.getPalette());
RGBColor color;
for(int row=0;row<gifBitmap.height();row++)
{
for(int col=0;col<gifBitmap.width();col++)
{
palette.getPaletteColor(gifBitmap.getByte(row,col),color);
setAt(row,col,RGB888(color.red(),color.green(),color.blue()));
}
}
return isOkay();
}
bool Image::handleOpenJPG(const String &strPathFileName,PureDevice &pureDevice)
{
JPGImage jpgImage;
RGB888 rgb888;
if(!jpgImage.decode(strPathFileName,pureDevice))return false;
create(jpgImage.width(),-jpgImage.height(),pureDevice);
for(int row=0;row<jpgImage.height();row++)
{
for(int col=0;col<jpgImage.width();col++)
{
jpgImage.getAt(row,col,rgb888);
setAt(row,col,rgb888);
}
}
return isOkay();
}
bool Image::handleOpenBMP(const String &strPathFileName,PureDevice &pureDevice)
{
OutputDebugString("Image::handleOpenBMP\n");
return isOkay();
}
bool Image::display(GUIWindow &window,const Rect &dstRect,const Point &srcPoint)
{
PureDevice pureDevice;
if(!isOkay())return false;
pureDevice=window;
draw(pureDevice,dstRect,srcPoint);
return false;
}
bool Image::display(GUIWindow &window)
{
PureDevice pureDevice;
Rect dstRect;
if(!isOkay())return false;
pureDevice=window;
dstRect.right(width());
dstRect.bottom(height());
draw(pureDevice,dstRect,Point());
return false;
}

39
meshwrp/image.hpp Normal file
View File

@@ -0,0 +1,39 @@
#ifndef _MESHWRP_IMAGE_HPP_
#define _MESHWRP_IMAGE_HPP_
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_GUIWINDOW_HPP_
#include <common/guiwnd.hpp>
#endif
#ifndef _COMMON_GUIWINDOW_HPP_
#include <common/guiwnd.hpp>
#endif
#ifndef _JPGIMG_DIB24_HPP_
#include <jpgimg/dib24.hpp>
#endif
class Image : public DIB24
{
public:
Image(void);
virtual ~Image();
Image &operator=(const Image &image);
bool open(String strPathFileName,GUIWindow &window);
bool newImage(LONG width,LONG height,GUIWindow &window);
bool display(GUIWindow &window,const Rect &dstRect,const Point &srcPoint);
bool display(GUIWindow &window);
private:
bool handleOpenGIF(const String &strPathFileName,PureDevice &pureDevice);
bool handleOpenJPG(const String &strPathFileName,PureDevice &pureDevice);
bool handleOpenBMP(const String &strPathFileName,PureDevice &pureDevice);
};
inline
Image &Image::operator=(const Image &image)
{
(DIB24&)*this=(DIB24&)image;
return *this;
}
#endif

992
meshwrp/imageview.cpp Normal file
View File

@@ -0,0 +1,992 @@
#include <meshwrp/imageview.hpp>
#include <meshwrp/resource.hpp>
#include <meshwrp/framedlg.hpp>
#include <meshwrp/factor.hpp>
#include <meshwrp/convex.hpp>
/*
#include <meshwrp/inifile.hpp>
#include <meshwrp/factor.hpp>
#include <meshwrp/frmdlg.hpp>
#include <meshwrp/paltdlg.hpp>
#include <meshwrp/resize.hpp>
#include <meshwrp/txlmtrx.hpp>
#include <meshwrp/shear.hpp>
#include <meshwrp/filehelp.hpp>
#include <meshwrp/main.hpp>
#include <meshwrp/segment.hpp>
#include <meshwrp/meshwrp.hpp>
#include <meshwrp/meshfrm.hpp>
#include <meshwrp/viewcntr.hpp>
#include <meshwrp/viewsel.hpp>
#include <meshwrp/dissolve.hpp>
#include <meshwrp/resource.hpp> */
//char ImageView::szClassName[]="GIFView";
//char ImageView::szMenuName[]="";
//HINSTANCE ImageView::smhInstance=0;
ImageView::ImageView()
/* : mhClientWindow(0), mhFrameWindow(0), mIsDestroyed(0),
mMaxColors(0), mWidth(0), mHeight(0), mhPalette(0),
mhGlobalInvert(0), mhGlobal(0), mhBMPGlobal(0), mpStatusBar(0),
mpProcessImage(0), mpBI(0), mhpImageInvert(0), mhpImage(0),
mhSystemMenu(0), mhFrameMenu(0), mhViewMenu(0), mpSpacial(0),
mpPerspectiveWarp(0), mlpClipboard(0), mlpToolBar(0), mlpGridMesh(0),
mlpConvexTransform(0), mToolbarVisibility(TRUE), mCurrentMeshFrames(DefaultFrames) */
: mCurrentMeshFrames(DefaultFrames)
{
mBkBrush.createHatchBrush(Brush::HDiagCross,RGBColor(128,128,128));
mPaintHandler.setCallback(this,&ImageView::paintHandler);
mCreateHandler.setCallback(this,&ImageView::createHandler);
mSizeHandler.setCallback(this,&ImageView::sizeHandler);
mVerticalScrollHandler.setCallback(this,&ImageView::verticalScrollHandler);
mHorizontalScrollHandler.setCallback(this,&ImageView::horizontalScrollHandler);
mEraseBackgroundHandler.setCallback(this,&ImageView::eraseBackgroundHandler);
installHandlers();
// mPathFileName[0]=0;
}
ImageView::ImageView(const ImageView &/*someImageView*/)
: mCurrentMeshFrames(DefaultFrames)
/*: mhClientWindow(0), mhFrameWindow(0), mIsDestroyed(0),
mMaxColors(0), mWidth(0), mHeight(0), mhPalette(0),
mhGlobalInvert(0), mhGlobal(0), mhBMPGlobal(0), mpStatusBar(0),
mpProcessImage(0), mpBI(0), mhpImageInvert(0), mhpImage(0),
mhSystemMenu(0), mhFrameMenu(0), mhViewMenu(0), mpSpacial(0),
mpPerspectiveWarp(0), mlpClipboard(0), mlpToolBar(0), mlpGridMesh(0),
mlpConvexTransform(0), mToolbarVisibility(TRUE), mCurrentMeshFrames(DefaultFrames) */
{
mBkBrush.createHatchBrush(Brush::HDiagCross,RGBColor(128,128,128));
mPaintHandler.setCallback(this,&ImageView::paintHandler);
mCreateHandler.setCallback(this,&ImageView::createHandler);
mSizeHandler.setCallback(this,&ImageView::sizeHandler);
mVerticalScrollHandler.setCallback(this,&ImageView::verticalScrollHandler);
mHorizontalScrollHandler.setCallback(this,&ImageView::horizontalScrollHandler);
mEraseBackgroundHandler.setCallback(this,&ImageView::eraseBackgroundHandler);
installHandlers();
}
ImageView::~ImageView()
{
removeHandlers();
/* if(mhPalette)::DeleteObject(mhPalette);
if(mhGlobalInvert)
{
::GlobalUnlock(mhGlobalInvert);
::GlobalFree(mhGlobalInvert);
}
if(mhBMPGlobal)
{
::GlobalUnlock(mhBMPGlobal);
::GlobalFree(mhBMPGlobal);
}
if(mhViewMenu)::DestroyMenu(mhViewMenu);
if(!mIsDestroyed && GetHandle())
::SendMessage(mhClientWindow,WM_MDIDESTROY,(WPARAM)GetHandle(),0L);
if(mlpToolBar)delete mlpToolBar;
if(mlpGridMesh)delete mlpGridMesh; */
}
void ImageView::installHandlers()
{
insertHandler(VectorHandler::PaintHandler,&mPaintHandler);
insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
insertHandler(VectorHandler::CreateHandler,&mCreateHandler);
insertHandler(VectorHandler::VerticalScrollHandler,&mVerticalScrollHandler);
insertHandler(VectorHandler::HorizontalScrollHandler,&mHorizontalScrollHandler);
insertHandler(VectorHandler::EraseBackgroundHandler,&mHorizontalScrollHandler);
}
void ImageView::removeHandlers()
{
removeHandler(VectorHandler::PaintHandler,&mPaintHandler);
removeHandler(VectorHandler::SizeHandler,&mSizeHandler);
removeHandler(VectorHandler::CreateHandler,&mCreateHandler);
removeHandler(VectorHandler::VerticalScrollHandler,&mVerticalScrollHandler);
removeHandler(VectorHandler::HorizontalScrollHandler,&mHorizontalScrollHandler);
removeHandler(VectorHandler::EraseBackgroundHandler,&mHorizontalScrollHandler);
}
CallbackData::ReturnType ImageView::createHandler(CallbackData &callbackData)
{
mScrollInfo.hwndOwner(*this);
return FALSE;
}
CallbackData::ReturnType ImageView::sizeHandler(CallbackData &callbackData)
{
mScrollInfo.handleSize(callbackData);
return FALSE;
}
CallbackData::ReturnType ImageView::horizontalScrollHandler(CallbackData &callbackData)
{
mScrollInfo.handleHorizontalScroll(callbackData);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType ImageView::verticalScrollHandler(CallbackData &callbackData)
{
mScrollInfo.handleVerticalScroll(callbackData);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType ImageView::eraseBackgroundHandler(CallbackData &callbackData)
{
return TRUE;
}
CallbackData::ReturnType ImageView::paintHandler(CallbackData &callbackData)
{
PaintInformation &paintInfo=*((PaintInformation*)callbackData.lParam());
PureDevice &paintDevice=(PureDevice&)paintInfo;
clearEmptyRegion(paintDevice);
if(mScrollInfo.sizeEvent())
{
mScrollInfo.sizeEvent(FALSE);
mImage.draw(paintDevice,Rect(0,0,mImage.width(),mImage.height()),Point(mScrollInfo.currScrollx(),mScrollInfo.currScrolly()));
}
if(mScrollInfo.scrollEvent()||(!mScrollInfo.sizeEvent()&&!mScrollInfo.scrollEvent()))
{
Rect paintRect(paintInfo.paintRect());
mScrollInfo.scrollEvent(FALSE);
paintRect.right(paintRect.right()-paintRect.left());
paintRect.bottom(paintRect.bottom()-paintRect.top());
mImage.draw(paintDevice,paintRect,Point(paintRect.left()+mScrollInfo.currScrollx(),paintRect.top()+mScrollInfo.currScrolly()));
}
return (CallbackData::ReturnType)FALSE;
}
void ImageView::clearEmptyRegion(PureDevice &pureDevice)
{
Rect imgRect;
Rect winRect;
Rect rtRect;
Rect btRect;
imgRect.right(mImage.width());
imgRect.bottom(mImage.height());
clientRect(winRect);
rtRect.left(winRect.right()>imgRect.right()?imgRect.right():winRect.right());
rtRect.right(winRect.right()>imgRect.right()?winRect.right():imgRect.right());
rtRect.bottom(winRect.bottom()>imgRect.bottom()?winRect.bottom():imgRect.bottom());
btRect.top(imgRect.bottom());
btRect.right(rtRect.left());
btRect.bottom(winRect.bottom());
pureDevice.fillRect(rtRect,mBkBrush);
pureDevice.fillRect(btRect,mBkBrush);
}
bool ImageView::open(const String &strPathFileName)
{
if(!mImage.open(strPathFileName,*this)){destroy();return false;}
mScrollInfo.scrollableObjectDimensions(mImage.width(),mImage.height());
show(SW_SHOW);
setTitle(strPathFileName);
invalidate(false);
setFocus();
return true;
}
void ImageView::operator=(Bitmap &someBitmap)
{
/* RGBQUAD FAR *pRGBQuad;
RGBStruct rgbStruct;
DWORD sizeBitmapInfo;
DWORD sizeImage;
HGLOBAL hGlobalSourceBitmapInfo;
HGLOBAL hGlobalSourceImage;
BITMAPINFO FAR *lpSourceBitmapInfo;
UHUGE *lpSourceImage;
hGlobalSourceBitmapInfo=someBitmap.lockedBitmapInfo();
#if defined(__FLAT__)
sizeBitmapInfo=::GlobalSize(hGlobalSourceBitmapInfo);
#else
sizeBitmapInfo=::GetSelectorLimit((UINT)hGlobalSourceBitmapInfo)+1L;
#endif
mhBMPGlobal=::GlobalAlloc(GMEM_FIXED,sizeBitmapInfo);
mpBI=(BITMAPINFO FAR *)::GlobalLock(mhBMPGlobal);
lpSourceBitmapInfo=(BITMAPINFO *)::GlobalLock(hGlobalSourceBitmapInfo);
Main::hmemcpy((UHUGE *)mpBI,(UHUGE *)lpSourceBitmapInfo,sizeBitmapInfo);
::GlobalUnlock(hGlobalSourceBitmapInfo);
sizeImage=((((mpBI->bmiHeader.biWidth*
mpBI->bmiHeader.biBitCount)+31)&~31)>>3)*
mpBI->bmiHeader.biHeight;
mhGlobalInvert=::GlobalAlloc(GMEM_FIXED,sizeImage);
mhpImageInvert=(UHUGE*)::GlobalLock(mhGlobalInvert);
hGlobalSourceImage=someBitmap.lockedImageData();
lpSourceImage=(UHUGE*)::GlobalLock(hGlobalSourceImage);
Main::hmemcpy(mhpImageInvert,lpSourceImage,sizeImage);
::GlobalUnlock(hGlobalSourceImage);
mWidth=(WORD)mpBI->bmiHeader.biWidth;
mHeight=(WORD)mpBI->bmiHeader.biHeight;
if(!(mMaxColors=(WORD)mpBI->bmiHeader.biClrUsed))
mMaxColors=1 << mpBI->bmiHeader.biBitCount;
for(int i=0;i<mMaxColors;i++)
{
pRGBQuad=(RGBQUAD FAR *)&mpBI->bmiColors[i];
rgbStruct.Red(pRGBQuad->rgbRed);
rgbStruct.Green(pRGBQuad->rgbGreen);
rgbStruct.Blue(pRGBQuad->rgbBlue);
mPaletteData.insert(&rgbStruct);
}
createPalette(); */
}
/*void ImageView::Paint(void)
{
RECT rect;
PAINTSTRUCT ps;
HDC hDC;
HPALETTE hOldPalette;
HWND activeWindow;
WORD menuState;
WORD errorCount=0;
::GetClientRect(GetHandle(),(RECT FAR *)&rect);
activeWindow=(HWND)LOWORD(::SendMessage(mhClientWindow,WM_MDIGETACTIVE,0,0L));
hDC=::BeginPaint(GetHandle(),&ps);
if(GetHandle()==activeWindow)hOldPalette=::SelectPalette(hDC,mhPalette,FALSE);
else hOldPalette=::SelectPalette(hDC,mhPalette,TRUE);
::RealizePalette(hDC);
menuState=::GetMenuState(mhSystemMenu,MenuConform,MF_BYCOMMAND);
if(!(menuState&MF_CHECKED))
::StretchDIBits(hDC,0,0,rect.right,rect.bottom,0,0,mWidth,mHeight,mhpImageInvert,(BITMAPINFO *)mpBI,DIB_RGB_COLORS,SRCCOPY);
else
{
while(!::StretchDIBits(hDC,0,0,mWidth,mHeight,0,0,mWidth,mHeight,mhpImageInvert,(BITMAPINFO *)mpBI,DIB_RGB_COLORS,SRCCOPY))
{
errorCount++;
::MessageBeep(0);
mWidth--;
mHeight--;
if((int)mWidth-1<0 || (int)mHeight-1<0)break;
::GlobalUnlock(mhGlobalInvert);
Resize resizeImage(mWidth+1,mHeight+1,mWidth,mHeight,mhGlobalInvert);
HGLOBAL hGlobalTemp=resizeImage.resizeImage();
::GlobalFree(mhGlobalInvert);
mhGlobalInvert=hGlobalTemp;
mhpImageInvert=(UHUGE *)::GlobalLock(hGlobalTemp);
mpBI->bmiHeader.biWidth=mWidth;
mpBI->bmiHeader.biHeight=mHeight;
}
if(errorCount)updateCaption();
}
if(GetHandle()==activeWindow)::SelectPalette(hDC,hOldPalette,FALSE);
else ::SelectPalette(hDC,hOldPalette,TRUE);
::EndPaint(GetHandle(),&ps);
if(mlpGridMesh)mlpGridMesh->suspendMesh(FALSE);
} */
void ImageView::updateCaption(void)const
{
/* char Buffer[MaxFileName];
char *ptr;
::GetWindowText(GetHandle(),(LPSTR)Buffer,sizeof(Buffer));
ptr=Buffer+::strlen(Buffer)-1;
while(*ptr!='-')ptr--;
ptr+=2;
::sprintf(ptr,"%dx%dx%d",mWidth,mHeight,mMaxColors);
::SetWindowText(GetHandle(),(LPSTR)Buffer); */
}
void ImageView::modifySystemMenu(void)
{
/* if(mhSystemMenu)return;
mhSystemMenu=::GetSystemMenu(GetHandle(),FALSE);
::AppendMenu(mhSystemMenu,MF_SEPARATOR,0,0);
::AppendMenu(mhSystemMenu,MF_STRING|MF_CHECKED,MenuConform,(LPSTR)"Non-Conforming");
::DrawMenuBar(GetHandle()); */
}
void ImageView::handleDestroyEvent()
{
/* if(mpProcessImage)mpProcessImage->cancelThread();
if(mpSpacial)mpSpacial->cancelThread();
if(mpPerspectiveWarp)mpPerspectiveWarp->cancelThread();
if(mlpConvexTransform)mlpConvexTransform->cancelThread();
if(mlpClipboard)delete mlpClipboard;
mIsDestroyed=TRUE; */
return;
}
void ImageView::handleActivateEvent(WPARAM wParam,LPARAM /*lParam*/)
{
/* if(wParam)
{
if(mlpGridMesh)mlpGridMesh->suspendMesh(TRUE);
HDC inhDC(::GetDC(GetHandle()));
::SelectPalette(inhDC,mhPalette,FALSE);
::SendMessage(mhFrameWindow,WM_COMMAND,IDM_INVALIDATEMDIWINDOWS,MAKELPARAM(0,0));
if(::RealizePalette(inhDC)>0)::InvalidateRect(GetHandle(),0,TRUE);
::ReleaseDC(GetHandle(),inhDC);
#if defined(__FLAT__)
::SendMessage(mhClientWindow,WM_MDISETMENU,(WPARAM)mhViewMenu,(LPARAM)::GetSubMenu(mhViewMenu,0));
#else
::SendMessage(mhClientWindow,WM_MDISETMENU,FALSE,MAKELONG(mhViewMenu,::GetSubMenu(mhViewMenu,0)));
#endif
if(mToolbarVisibility&&mlpToolBar&&!mlpToolBar->isVisible())mlpToolBar->showWindow();
}
else
{
if(mlpToolBar&&mlpToolBar->isVisible())mlpToolBar->showWindow(FALSE);
if(mlpGridMesh)mlpGridMesh->showWindow(TRUE);
#if defined(__FLAT__)
::SendMessage(mhClientWindow,WM_MDISETMENU,(WPARAM)mhFrameMenu,(LPARAM)0);
#else
::SendMessage(mhClientWindow,WM_MDISETMENU,FALSE,MAKELONG(mhFrameMenu,0));
#endif
}
::DrawMenuBar(mhFrameWindow); */
return;
}
/* long ImageView::WndProc(UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CREATE :
{
char buffer[100];
mlpClipboard=new Clipboard(GetHandle());
assert(0!=mlpClipboard);
::SetWindowText(GetHandle(),(LPSTR)mPathFileName);
::sprintf(buffer,"%s - %dx%dx%d",mPathFileName,mWidth,mHeight,mMaxColors);
::SetWindowText(GetHandle(),(LPSTR)buffer);
modifySystemMenu();
mCapture=GetHandle();
::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
return FALSE;
case WM_CHANGECBCHAIN :
if(!mlpClipboard)break;
mlpClipboard->changeClipboardChain(message,wParam,lParam);
return FALSE;
case WM_DRAWCLIPBOARD :
if(!mlpClipboard)break;
if(mlpClipboard->drawClipboard(message,wParam,lParam))
::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_ENABLED);
return FALSE;
case WM_LBUTTONDOWN :
mCapture.leftButtonDown(lParam);
return FALSE;
case WM_MOUSEMOVE :
mCapture.mouseMove(lParam);
return FALSE;
case WM_LBUTTONUP :
mCapture.leftButtonUp();
return FALSE;
case WM_PAINT :
Paint();
return FALSE;
case WM_MDIACTIVATE :
#if defined(__FLAT__)
handleActivateEvent((WPARAM)lParam,(LPARAM)wParam);
#else
handleActivateEvent(wParam,lParam);
#endif
return FALSE;
case WM_QUERYENDSESSION :
break;
case WM_DESTROY :
handleDestroyEvent();
return FALSE;
case WM_SYSCOMMAND :
handleSystemMenuEvent(wParam);
break;
case WM_COMMAND :
switch(GET_WM_COMMAND_ID(wParam,lParam))
{
case MenuConform :
::SendMessage(GetHandle(),WM_SYSCOMMAND,MenuConform,0L);
return FALSE;
case MENU_SMOOTHING :
imageProcessing();
return FALSE;
case MENU_RESIZE :
resizeImage();
return FALSE;
case MENU_TRANSLATE :
translateMatrix();
return FALSE;
case MENU_SHEAR :
shearTransform();
return FALSE;
case MENU_WARP_PERSPECTIVE :
warpPerspective();
return FALSE;
case MENU_WARP_CONVEX :
warpConvex();
return FALSE;
case MENU_CLIP :
menuClip();
return FALSE;
case MENU_DISSOLVE :
{
AdjustDissolve adjustDissolve(GetHandle());
adjustDissolve.adjustDissolve(mDissolveSchedule,mCurrentMeshFrames);
}
return FALSE;
case MENU_TBSIGMA :
{
FrameDialog frameDialog(GetHandle());
frameDialog.performFrameDialog(mCurrentMeshFrames);
}
return FALSE;
case MENU_TBLOAD :
case MENU_TBSAVE :
case MENU_TBTRANSFORMB :
case MENU_TBTRANSFORMA :
case IDM_WINLIST :
handleMeshRequest(wParam,lParam);
return FALSE;
case MENU_TBCLIP :
mCapture.reset();
if(mlpGridMesh)
{
delete mlpGridMesh;
mlpGridMesh=0;
}
return FALSE;
case MENU_TBMESH :
if(!mlpGridMesh)mlpGridMesh=new GridMesh(GetHandle(),mWidth,mHeight);
else mlpGridMesh->newMesh(mlpGridMesh->gridLines()+2);
return FALSE;
case MENU_FILE_SAVEBITMAP :
saveBitmap();
return FALSE;
case MENU_PALETTE_VIEW :
{
PaletteDialog viewPalette(GetHandle(),mhPalette);
viewPalette.showPalette();
return FALSE;
}
case IDM_TOOLBAR :
handleToolbarToggle();
break;
default :
return FALSE;
}
}
return ::DefMDIChildProc(GetHandle(),message,wParam,lParam);
} */
// **************************************************************
void ImageView::handleToolbarToggle(void)
{
/* String showToolbarString(STRING_SHOWTOOLBAR,Main::processInstance());
String hideToolbarString(STRING_HIDETOOLBAR,Main::processInstance());
String menuString;
::GetMenuString(mhViewMenu,IDM_TOOLBAR,menuString,String::MaxString,MF_BYCOMMAND);
if(showToolbarString==menuString)
{
::ModifyMenu(mhViewMenu,IDM_TOOLBAR,MF_STRING|MF_ENABLED,IDM_TOOLBAR,(LPSTR)hideToolbarString);
mlpToolBar->showWindow(TRUE);
mToolbarVisibility=TRUE;
}
else
{
::ModifyMenu(mhViewMenu,IDM_TOOLBAR,MF_STRING|MF_ENABLED,IDM_TOOLBAR,(LPSTR)showToolbarString);
mlpToolBar->showWindow(FALSE);
mToolbarVisibility=FALSE;
}
::DrawMenuBar(GetHandle()); */
}
void ImageView::handleMeshRequest(WPARAM wParam,LPARAM lParam)
{
/* String meshFileName(mPathFileName);
String meshPathFileName;
IniFile iniSettings;
iniSettings.makeFileName(meshFileName);
meshFileName.token(".\0");
meshFileName+=".MSH";
meshPathFileName=iniSettings.meshDirectory();
meshPathFileName+=meshFileName;
switch(wParam)
{
case MENU_TBLOAD :
if(!mlpGridMesh)mlpGridMesh=new GridMesh(GetHandle(),mWidth,mHeight,GridMesh::NoShow);
mlpGridMesh->loadMesh(meshPathFileName);
break;
case MENU_TBTRANSFORMA :
if(!mlpGridMesh){::MessageBeep(0);break;}
meshWarp();
break;
case MENU_TBTRANSFORMB :
if(!mlpGridMesh){::MessageBeep(0);break;}
::PostMessage(mhFrameWindow,WM_COMMAND,IDM_GETWINLIST,MAKELPARAM(GetHandle(),0));
break;
case IDM_WINLIST :
{
WORD itemIndex;
Block<ViewContainer> *lpViewBlock=(Block<ViewContainer>*)(lParam);
if(!lpViewBlock||!lpViewBlock->size()){::MessageBeep(0);break;}
ViewSelect selectView(GetHandle());
if(selectView.selectView(*lpViewBlock,itemIndex,mWidth,mHeight))meshWarp((*lpViewBlock)[itemIndex].windowPtr());
delete lpViewBlock;
}
break;
case MENU_TBSAVE :
if(!mlpGridMesh)break;
mlpGridMesh->saveMesh(meshPathFileName);
break;
} */
return;
}
void ImageView::handleSystemMenuEvent(WPARAM wParam)const
{
/* WORD menuState;
switch(wParam)
{
case MenuConform :
menuState=::GetMenuState(mhSystemMenu,MenuConform,MF_BYCOMMAND);
::CheckMenuItem(mhSystemMenu,MenuConform,MF_BYCOMMAND |
(menuState&MF_CHECKED?MF_UNCHECKED:MF_CHECKED));
::DrawMenuBar(GetHandle());
::InvalidateRect(GetHandle(),NULL,TRUE);
} */
}
void ImageView::enableMenu(const char isEnabled)const
{
/* if(isEnabled)
{
::EnableMenuItem(mhViewMenu,MENU_CUT,MF_BYCOMMAND|MF_ENABLED);
::EnableMenuItem(mhViewMenu,MENU_COPY,MF_BYCOMMAND|MF_ENABLED);
::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_ENABLED);
::EnableMenuItem(mhViewMenu,MENU_SMOOTHING,MF_BYCOMMAND|MF_ENABLED);
::EnableMenuItem(mhViewMenu,MENU_RESIZE,MF_BYCOMMAND|MF_ENABLED);
::EnableMenuItem(mhViewMenu,MENU_TRANSLATE,MF_BYCOMMAND|MF_ENABLED);
::EnableMenuItem(mhViewMenu,MENU_WARP_PERSPECTIVE,MF_BYCOMMAND|MF_ENABLED);
::EnableMenuItem(mhViewMenu,MENU_FILE_SAVEBITMAP,MF_BYCOMMAND|MF_ENABLED);
}
else
{
::EnableMenuItem(mhViewMenu,MENU_CUT,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(mhViewMenu,MENU_COPY,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(mhViewMenu,MENU_SMOOTHING,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(mhViewMenu,MENU_RESIZE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(mhViewMenu,MENU_TRANSLATE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(mhViewMenu,MENU_WARP_PERSPECTIVE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
::EnableMenuItem(mhViewMenu,MENU_FILE_SAVEBITMAP,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
} */
}
void ImageView::imageProcessing(void)
{
/* enableMenu(FALSE);
mpProcessImage=new Process(mhPalette,mhpImageInvert,mWidth,mHeight);
if(mpProcessImage->showProcess(GetHandle(),mPathFileName) && !mIsDestroyed)
::InvalidateRect(GetHandle(),NULL,TRUE);
if(!mIsDestroyed)enableMenu(TRUE);
delete mpProcessImage;
mpProcessImage=0; */
}
void ImageView::resizeImage(void)
{
double sizeFactor;
Factor resizeFactor(*this,"Resize Factor");
if(!resizeFactor.showFactor(sizeFactor,sizeFactor)||0.00==sizeFactor)return;
/* HGLOBAL hGlobal;
double sizeFactor;
Factor resizeFactor(GetHandle(),"Resize Factor");
if(!resizeFactor.showFactor(sizeFactor,sizeFactor)||!sizeFactor)return;
enableMenu(FALSE);
mpSpacial=new SpacialTransform(mhPalette,mhpImageInvert,mWidth,mHeight,sizeFactor);
hGlobal=mpSpacial->resizeImage();
if(mpSpacial->isCancelled())
{
delete mpSpacial;
mpSpacial=0;
return;
}
delete mpSpacial;
mpSpacial=0;
if(hGlobal)
{
mWidth*=(sizeFactor/100.00);
mHeight*=(sizeFactor/100.00);
::GlobalUnlock(mhGlobalInvert);
::GlobalFree(mhGlobalInvert);
mhGlobalInvert=hGlobal;
mhpImageInvert=(UHUGE *)::GlobalLock(mhGlobalInvert);
mpBI->bmiHeader.biWidth=mWidth;
mpBI->bmiHeader.biHeight=mHeight;
}
::InvalidateRect(GetHandle(),NULL,TRUE);
enableMenu(TRUE);
updateCaption(); */
}
void ImageView::menuClip(void)
{
/* RECT copyRect;
HGLOBAL hGlobalResizedImage;
UHUGE *ptrResizedImage;
if(!mCapture.hasRectangle())return;
mCapture.boundedRect(copyRect);
enableMenu(FALSE);
::GlobalUnlock(mhGlobalInvert);
Resize resizeImage(mWidth,mHeight,copyRect,mhGlobalInvert);
if(0!=(hGlobalResizedImage=resizeImage.resizeImage()))
{
::GlobalFree(mhGlobalInvert);
ptrResizedImage=(UHUGE *)::GlobalLock(hGlobalResizedImage);
mhGlobalInvert=hGlobalResizedImage;
mhpImageInvert=ptrResizedImage;
mpBI->bmiHeader.biWidth=mWidth=(copyRect.right-copyRect.left)+1;
mpBI->bmiHeader.biHeight=mHeight=(copyRect.bottom-copyRect.top)+1;
::InvalidateRect(GetHandle(),NULL,TRUE);
}
else ::GlobalLock(mhGlobalInvert);
updateCaption();
enableMenu(TRUE); */
}
void ImageView::saveBitmap(void)
{
/* char bitmapName[MaxFileName];
SelectFile selector(GetHandle(),SelectFile::Write);
selector.SetFileSpec(String(STRING_ASTERISKDOTBMP,Main::processInstance()));
if(selector.GetFileName(bitmapName,sizeof(bitmapName)))
{
waitCursor(TRUE);
Bitmap bitmapImage(bitmapName,mhGlobalInvert,mhBMPGlobal);
bitmapImage.saveBitmap();
waitCursor(FALSE);
} */
}
void ImageView::translateMatrix(void)
{
/* UHUGE *ptr;
double xFactor;
double yFactor;
Factor resizeFactor(GetHandle(),"Translate Factor");
if(!resizeFactor.showFactor(yFactor,xFactor))return;
if(!yFactor && !xFactor)return;
enableMenu(FALSE);
waitCursor(TRUE);
yFactor*=-1;
xFactor*=-1;
HGLOBAL hGlobal=::GlobalAlloc(GMEM_FIXED,(LONG)mWidth*(LONG)mHeight);
ptr=(UHUGE*)::GlobalLock(hGlobal);
TranslationMatrix translation(mHeight,mWidth,(int)xFactor,(int)yFactor,&mhpImageInvert,&ptr);
translation.performTranslation();
::GlobalUnlock(mhGlobalInvert);
::GlobalFree(mhGlobalInvert);
mhGlobalInvert=hGlobal;
mhpImageInvert=ptr;
::InvalidateRect(GetHandle(),NULL,TRUE);
waitCursor(FALSE);
enableMenu(TRUE); */
}
void ImageView::shearTransform(void)
{
/* HGLOBAL hGlobalTemp;
WORD width(mWidth);
WORD height(mHeight);
double xFactor(0.3);
double yFactor(0.00);
Factor shearFactor(GetHandle(),"Shear Factors");
if(!shearFactor.showFactor(xFactor,yFactor))return;
Shear shearTransform;
hGlobalTemp=shearTransform.performShear
(width,height,xFactor,yFactor,mhpImageInvert);
if(hGlobalTemp)
{
::GlobalUnlock(mhGlobalInvert);
::GlobalFree(mhGlobalInvert);
mpBI->bmiHeader.biWidth=mWidth=width;
mpBI->bmiHeader.biHeight=mHeight=height;
mhGlobalInvert=hGlobalTemp;
mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp);
}
::InvalidateRect(GetHandle(),NULL,TRUE); */
}
void ImageView::warpPerspective(void)
{
/* HGLOBAL hGlobalTemp;
Factor::Operation widthOperation;
Factor::Operation heightOperation;
double widthIncremental;
double heightIncremental;
double wRow;
double wCol;
WORD isCancelled;
Factor resizeFactor(GetHandle(),"Perpective Warp");
if(!resizeFactor.showFactor(
wRow,wCol,
widthIncremental,widthOperation,
heightIncremental,heightOperation
))return;
enableMenu(FALSE);
if(Factor::None==widthOperation&&Factor::None==heightOperation)
mpPerspectiveWarp=new PerspectiveWarp(mWidth,mHeight,mhpImageInvert,wRow,wCol);
else
mpPerspectiveWarp=new PerspectiveWarp(mWidth,mHeight,wRow,wCol,
(PerspectiveWarp::Operation)widthOperation,widthIncremental,
(PerspectiveWarp::Operation)heightOperation,heightIncremental,mhpImageInvert);
hGlobalTemp=mpPerspectiveWarp->performPerspectiveWarp();
isCancelled=mpPerspectiveWarp->isCancelled();
delete mpPerspectiveWarp;
mpPerspectiveWarp=0;
enableMenu(TRUE);
if(isCancelled)return;
if(hGlobalTemp)
{
::GlobalUnlock(mhGlobalInvert);
::GlobalFree(mhGlobalInvert);
mhGlobalInvert=hGlobalTemp;
mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp);
}
::InvalidateRect(GetHandle(),NULL,TRUE); */
}
void ImageView::handleWarpConvex(void)
{
Convex convex;
Image image;
mImage=convex.performConvex(mImage,*this);
invalidate(false);
/* HGLOBAL hGlobalTemp;
WORD isCancelled;
mlpConvexTransform=new Convex;
hGlobalTemp=mlpConvexTransform->performConvex(mWidth,mHeight,mhpImageInvert);
isCancelled=mlpConvexTransform->isCancelled();
delete mlpConvexTransform;
mlpConvexTransform=0;
if(isCancelled)return;
if(hGlobalTemp)
{
::GlobalUnlock(mhGlobalInvert);
::GlobalFree(mhGlobalInvert);
mhGlobalInvert=hGlobalTemp;
mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp);
}
::InvalidateRect(GetHandle(),NULL,TRUE); */
}
// *********************************************************************************
void ImageView::meshWarp(Direction warpDirection)
{
/* Vector<FloatPairs> sourcePairs;
Vector<FloatPairs> destPairs;
Vector<MeshFrames::VectoredPairs> meshFrames;
Vector<Point> sourcePoints;
Vector<Point> destPoints;
Block<String> intermediatePathFileNames;
HGLOBAL hGlobalOriginal;
UHUGE *lpOriginal;
int originalWidth;
int originalHeight;
HGLOBAL hGlobalTemp(0);
MeshFrames meshFrame;
int newWidth;
int newHeight;
size_t size;
mlpGridMesh->retrieveMesh(sourcePoints,destPoints);
if((size=(int)sourcePoints.size())!=destPoints.size())return;
sourcePairs.size(destPairs.size(size));
for(int i=0;i<size;i++)
{
sourcePairs[i].setPairs(sourcePoints[i].xPoint(),sourcePoints[i].yPoint());
destPairs[i].setPairs(destPoints[i].xPoint(),destPoints[i].yPoint());
}
if(WarpForward==warpDirection)
meshFrame.interpolateMeshFrames(sourcePairs,destPairs,meshFrames,mCurrentMeshFrames);
else
meshFrame.interpolateMeshFrames(destPairs,sourcePairs,meshFrames,mCurrentMeshFrames);
hGlobalOriginal=::GlobalAlloc(GMEM_FIXED,(LONG)mWidth*(LONG)mHeight);
lpOriginal=(UHUGE*)::GlobalLock(hGlobalOriginal);
originalWidth=mWidth;
originalHeight=mHeight;
Main::hmemcpy(lpOriginal,mhpImageInvert,(LONG)mWidth*(LONG)mHeight);
sequentialNames(mPathFileName,intermediatePathFileNames,mCurrentMeshFrames);
Bitmap bitmapImage(intermediatePathFileNames[0],hGlobalOriginal,mhBMPGlobal);
bitmapImage.saveBitmap();
for(i=0;i<mCurrentMeshFrames-1;i++)
{
MeshWarp meshWarp(mhPalette,lpOriginal,originalWidth,originalHeight);
hGlobalTemp=meshWarp.performWarp(sourcePairs,meshFrames[i],mlpGridMesh->rowCols(),newWidth,newHeight);
::GlobalUnlock(mhGlobalInvert);
::GlobalFree(mhGlobalInvert);
if(!hGlobalTemp)break;
mhGlobalInvert=hGlobalTemp;
mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp);
mpBI->bmiHeader.biWidth=mWidth=newWidth;
mpBI->bmiHeader.biHeight=mHeight=newHeight;
::InvalidateRect(GetHandle(),NULL,TRUE);
::UpdateWindow(GetHandle());
Bitmap bitmapImage(intermediatePathFileNames[i+1],mhGlobalInvert,mhBMPGlobal);
bitmapImage.saveBitmap();
}
if(!hGlobalTemp)
{
String tempString;
::sprintf(tempString,"Warp failed at %d",i);
::MessageBox(GetHandle(),(LPSTR)tempString,(LPSTR)"WARP ERROR",MB_ICONASTERISK);
mhGlobalInvert=hGlobalOriginal;
mhpImageInvert=lpOriginal;
mpBI->bmiHeader.biWidth=mWidth=originalWidth;
mpBI->bmiHeader.biHeight=mHeight=originalHeight;
}
else
{
::GlobalUnlock(hGlobalOriginal);
::GlobalFree(hGlobalOriginal);
}
if(WarpForward==warpDirection)createProjectFile(intermediatePathFileNames);
::InvalidateRect(GetHandle(),NULL,TRUE);
mlpGridMesh->showWindow(); */
}
void ImageView::meshWarp(ImageView *lpTargetView)
{
/* Block<String> intermediateSrcImage;
Block<String> intermediateDstImage;
CrossDissolve crossDissolve;
WORD currentTargetFrames;
meshWarp();
currentTargetFrames=lpTargetView->mCurrentMeshFrames;
lpTargetView->mCurrentMeshFrames=mCurrentMeshFrames;
lpTargetView->meshWarp(WarpReverse);
sequentialNames(mPathFileName,intermediateSrcImage,mCurrentMeshFrames);
lpTargetView->sequentialNames(lpTargetView->mPathFileName,intermediateDstImage,lpTargetView->mCurrentMeshFrames);
if(mDissolveSchedule.size())
crossDissolve.crossDissolve(intermediateSrcImage,intermediateDstImage,mDissolveSchedule);
else crossDissolve.crossDissolve(intermediateSrcImage,intermediateDstImage);
lpTargetView->mCurrentMeshFrames=currentTargetFrames; */
}
void ImageView::createProjectFile(Block<String> &pathFileNames)
{
/* String projectIDString(STRING_PROJECTIDSTRING,Main::processInstance());
String projectExtension(STRING_PROJECTEXTENSION,Main::processInstance());
String carriageReturn(STRING_CRLF,Main::processInstance());
String dotString(STRING_DOT,Main::processInstance());
String fileNameString;
size_t size((int)pathFileNames.size());
if(!size)return;
fileNameString=pathFileNames[0];
fileNameString.token(dotString);
fileNameString+=projectExtension;
ofstream outputProject(fileNameString);
if(!outputProject.fail()&&!outputProject.bad())
{
outputProject << (LPSTR)projectIDString << (LPSTR)carriageReturn;
for(int i=0;i<size;i++)outputProject << (LPSTR)pathFileNames[i] << (LPSTR)carriageReturn;
} */
}
void ImageView::sequentialNames(const String &pathFileName,Block<String> &pathFileNames,int nFrames)
{
/* IniFile iniSettings;
String currentExtension(STRING_MESHEXTENSION,Main::processInstance());
String dotString(STRING_DOT,Main::processInstance());
String tempString(pathFileName);
String intermediatePathFileName;
pathFileNames.remove();
iniSettings.makeFileName(tempString);
intermediatePathFileName=iniSettings.projectDirectory();
intermediatePathFileName+=tempString;
for(int i=0;i<nFrames;i++)
{
intermediatePathFileName.token(dotString);
::sprintf(currentExtension,".%03d",i);
intermediatePathFileName+=currentExtension;
pathFileNames.insert(&intermediatePathFileName);
} */
}
bool ImageView::operator==(const ImageView &imageView)const
{
String strThisTitle;
String strOtherTitle;
windowText(strThisTitle);
imageView.windowText(strOtherTitle);
return strThisTitle==strOtherTitle;
}
void ImageView::setTitle(const String &strTitle)
{
String strCaption;
String strString;
windowText(strCaption);
strString=strCaption;
strCaption=strCaption.betweenString(0,' ');
if(strCaption.isNull())strCaption=strString;
strCaption+=String(" - [")+strTitle+String("]");
setCaption(strCaption);
}
void ImageView::showMesh(void)
{
if(mGridMesh.isOkay())mGridMesh->newMesh(mGridMesh->gridLines()+2);
else
{
mGridMesh.destroy();
mGridMesh=::new GridMesh(*this,mImage.width(),mImage.height());
mGridMesh.disposition(PointerDisposition::Delete);
mGridMesh->showWindow();
}
}
void ImageView::noMesh(void)
{
if(!mGridMesh.isOkay())return;
mGridMesh.destroy();
}
void ImageView::handleFrames(void)
{
FrameDialog frameDialog(*this);
frameDialog.perform(mCurrentMeshFrames);
}
// ***** virtual overloads
void ImageView::preRegister(WNDCLASS &wndClass)
{
wndClass.style|=CS_SAVEBITS|CS_OWNDC;
wndClass.hbrBackground=(HBRUSH)::GetStockObject(GRAY_BRUSH);
}
void ImageView::preCreate(MDICREATESTRUCT &createStruct)
{
createStruct.style=WS_SYSMENU|WS_CAPTION|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VSCROLL|WS_HSCROLL;
}

176
meshwrp/imageview.hpp Normal file
View File

@@ -0,0 +1,176 @@
#ifndef _MESHWRP_IMAGEVIEW_HPP_
#define _MESHWRP_IMAGEVIEW_HPP_
#ifndef _COMMON_MDIWIN_HPP_
#include <common/mdiwin.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
#ifndef _COMMON_BRUSH_HPP_
#include <common/brush.hpp>
#endif
#ifndef _TOOLBAR_TOOLBAR_HPP_
#include <toolbar/toolbar.hpp>
#endif
#ifndef _MESHWRP_MESH_HPP_
#include <meshwrp/mesh.hpp>
#endif
#ifndef _MESHWRP_SCROLLINFO_HPP_
#include <meshwrp/scroll.hpp>
#endif
#ifndef _MESHWRP_IMAGE_HPP_
#include <meshwrp/image.hpp>
#endif
/*
#include <meshwrp/main.hpp>
#include <meshwrp/capture.hpp>
#include <meshwrp/mdiwin.hpp>
#include <meshwrp/gif.hpp>
#include <meshwrp/process.hpp>
#include <meshwrp/spacial.hpp>
#include <meshwrp/pwarp.hpp>
#include <meshwrp/convex.hpp>
#include <meshwrp/average.hpp>
#include <meshwrp/clipbrd.hpp>
#include <meshwrp/toolbar.hpp>
#include <meshwrp/mesh.hpp>
#include <meshwrp/dslvdlg.hpp>
#include <meshwrp/rgb.hpp>
#include <meshwrp/schedule.hpp>
*/
class BWindow;
class ImageView : public MDIWindow
{
public:
enum Direction{WarpForward,WarpReverse};
ImageView(void);
ImageView(const ImageView &someImageView);
virtual ~ImageView();
bool open(const String &strPathFileName);
bool operator==(const ImageView &imageView)const;
bool hasMesh(void)const;
void showMesh(void);
void noMesh(void);
void handleFrames(void);
void resizeImage(void);
void handleWarpConvex(void);
void meshWarp(Direction warpDirection=WarpForward);
protected:
virtual void preRegister(WNDCLASS &wndClass);
virtual void preCreate(MDICREATESTRUCT &createStruct);
private:
enum {DefaultFrames=3};
enum {MenuConform=0x0F};
CallbackData::ReturnType paintHandler(CallbackData &callbackData);
CallbackData::ReturnType sizeHandler(CallbackData &callbackData);
CallbackData::ReturnType createHandler(CallbackData &callbackData);
CallbackData::ReturnType verticalScrollHandler(CallbackData &callbackData);
CallbackData::ReturnType horizontalScrollHandler(CallbackData &callbackData);
CallbackData::ReturnType eraseBackgroundHandler(CallbackData &callbackData);
void clearEmptyRegion(PureDevice &pureDevice);
ImageView &operator=(const ImageView &imageView);
void setTitle(const String &strTitle);
void installHandlers(void);
void removeHandlers(void);
void handleMeshRequest(WPARAM wParam,LPARAM lParam);
void handleDestroyEvent(void);
void handleActivateEvent(WPARAM wParam,LPARAM lParam);
void handleSystemMenuEvent(WPARAM wParam)const;
void handleToolbarToggle(void);
void enableMenu(const char isEnabled)const;
void modifySystemMenu(void);
void updateCaption(void)const;
void operator=(Bitmap &someBitmap);
void imageProcessing(void);
void menuClip(void);
void meshWarp(ImageView *lpTargetView);
void warpPerspective(void);
void warpConvex(void);
void translateMatrix(void);
void shearTransform(void);
void saveBitmap(void);
void sequentialNames(const String &pathFileName,Block<String> &pathFileNames,int nFrames);
void createProjectFile(Block<String> &pathFileNames);
Image mImage;
ScrollInfo mScrollInfo;
Brush mBkBrush;
SmartPointer<GridMesh> mGridMesh;
SmartPointer<ToolBar> mToolControl;
Callback<ImageView> mCreateHandler;
Callback<ImageView> mSizeHandler;
Callback<ImageView> mPaintHandler;
Callback<ImageView> mVerticalScrollHandler;
Callback<ImageView> mHorizontalScrollHandler;
Callback<ImageView> mEraseBackgroundHandler;
DWORD mCurrentMeshFrames;
// static char szClassName[];
// static char szMenuName[];
// static HINSTANCE smhInstance;
/* int mCurrentMeshFrames;
WORD mToolbarVisibility;
WORD mMaxColors;
WORD mWidth;
WORD mHeight;
char mPathFileName[MaxFileName+1];
Capture mCapture;
HWND mhClientWindow;
HWND mhFrameWindow;
WORD mIsDestroyed;
HMENU mhSystemMenu;
HMENU mhFrameMenu;
HMENU mhViewMenu;
HPALETTE mhPalette;
HGLOBAL mhGlobalInvert;
HGLOBAL mhGlobal;
HGLOBAL mhBMPGlobal;
Clipboard *mlpClipboard;
BWindow *mpStatusBar;
Process *mpProcessImage;
SpacialTransform *mpSpacial;
PerspectiveWarp *mpPerspectiveWarp;
Convex *mlpConvexTransform;
BITMAPINFO FAR *mpBI;
UHUGE *mhpImageInvert;
UHUGE *mhpImage;
ToolBar *mlpToolBar;
GridMesh *mlpGridMesh;
Block<RGBStruct> mPaletteData;
Block<Schedule> mDissolveSchedule; */
};
inline
bool ImageView::hasMesh(void)const
{
return mGridMesh.isOkay();
}
#endif

19
meshwrp/img.pal Normal file
View File

@@ -0,0 +1,19 @@
JASC-PAL
0100
16
0 0 0
191 0 0
0 191 0
191 191 0
0 0 191
191 0 191
0 191 191
192 192 192
128 128 128
255 0 0
0 255 0
255 255 0
0 0 255
255 0 255
0 255 255
255 255 255

BIN
meshwrp/io.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

9
meshwrp/main.cpp Normal file
View File

@@ -0,0 +1,9 @@
#include <meshwrp/mainfrm.hpp>
#include <meshwrp/resource.hpp>
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
{
MainFrame frameWindow;
frameWindow.createWindow("MeshWarp",String(STRING_APPNAME)+String(" ")+String(STRING_APPVERSION),"mdiMainMenu","P944");
return ((FrameWindow&)frameWindow).messageLoop();
}

67
meshwrp/main.hpp Normal file
View File

@@ -0,0 +1,67 @@
#ifndef _MESHWRP_MAIN_HPP_
#define _MESHWRP_MAIN_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
class Main
{
public:
static HINSTANCE processInstance(HWND hWnd);
static HINSTANCE processInstance(void);
static HINSTANCE previousProcessInstance(void);
static void processInstance(HINSTANCE processInstance);
static void previousProcessInstance(HINSTANCE previousProcessInstance);
static void cmdShow(int nCmdShow);
private:
static HINSTANCE smhInstance;
static HINSTANCE smhPrevInstance;
static int smnCmdShow;
};
inline
void Main::processInstance(HINSTANCE hProcessInstance)
{
smhInstance=hProcessInstance;
}
inline
void Main::previousProcessInstance(HINSTANCE previousProcessInstance)
{
smhPrevInstance=previousProcessInstance;
}
inline
void Main::cmdShow(int nCmdShow)
{
}
inline
HINSTANCE Main::processInstance(void)
{
return smhInstance;
}
inline
HINSTANCE Main::previousProcessInstance(void)
{
return smhPrevInstance;
}
#if defined(__FLAT__)
inline
HINSTANCE Main::processInstance(HWND hWnd)
{
return (HINSTANCE)::GetWindowLong(hWnd,GWL_HINSTANCE);
}
#else
inline
HINSTANCE Main::processInstance(HWND hWnd)
{
return (HINSTANCE)::GetWindowWord(hWnd,GWW_HINSTANCE);
}
#endif
#define WM_REACTIVATE WM_USER+1
#endif

424
meshwrp/mainfrm.cpp Normal file
View File

@@ -0,0 +1,424 @@
#include <meshwrp/mainfrm.hpp>
#include <meshwrp/resource.hpp>
#include <meshwrp/imageview.hpp>
#include <common/stdio.hpp>
#include <common/diskinfo.hpp>
#include <common/openfile.hpp>
#include <common/opendlg.hpp>
#include <statbar/statbarx.hpp>
#include <tooltip/toolinfo.hpp>
MainFrame::MainFrame(void)
{
mPaintHandler.setCallback(this,&MainFrame::paintHandler);
mCloseHandler.setCallback(this,&MainFrame::closeHandler);
mQueryEndSessionHandler.setCallback(this,&MainFrame::queryEndSessionHandler);
mDestroyHandler.setCallback(this,&MainFrame::destroyHandler);
mCommandHandler.setCallback(this,&MainFrame::commandHandler);
mKeyDownHandler.setCallback(this,&MainFrame::keyDownHandler);
mSizeHandler.setCallback(this,&MainFrame::sizeHandler);
mCreateHandler.setCallback(this,&MainFrame::createHandler);
insertHandlers();
}
MainFrame::~MainFrame()
{
removeHandlers();
}
void MainFrame::insertHandlers(void)
{
FrameWindow::insertHandler(MainFrame::DestroyHandler,&mDestroyHandler);
FrameWindow::insertHandler(VectorHandler::PaintHandler,&mPaintHandler);
FrameWindow::insertHandler(VectorHandler::CommandHandler,&mCommandHandler);
FrameWindow::insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
FrameWindow::insertHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler);
FrameWindow::insertHandler(VectorHandler::CloseHandler,&mCloseHandler);
FrameWindow::insertHandler(VectorHandler::QueryEndSessionHandler,&mQueryEndSessionHandler);
FrameWindow::insertHandler(VectorHandler::CreateHandler,&mCreateHandler);
}
void MainFrame::removeHandlers(void)
{
FrameWindow::removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
FrameWindow::removeHandler(VectorHandler::PaintHandler,&mPaintHandler);
FrameWindow::removeHandler(VectorHandler::CommandHandler,&mCommandHandler);
FrameWindow::removeHandler(VectorHandler::SizeHandler,&mSizeHandler);
FrameWindow::removeHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler);
FrameWindow::removeHandler(VectorHandler::CreateHandler,&mCreateHandler);
FrameWindow::removeHandler(VectorHandler::CloseHandler,&mCloseHandler);
FrameWindow::removeHandler(VectorHandler::QueryEndSessionHandler,&mQueryEndSessionHandler);
}
CallbackData::ReturnType MainFrame::commandHandler(CallbackData &someCallbackData)
{
switch(someCallbackData.wParam())
{
case IDM_CASCADE :
cascade();
break;
case IDM_TILE :
tile();
break;
case IDM_ARRANGE :
arrange();
break;
case IDM_CLOSEALL :
closeAll();
break;
case IDM_MINIMIZEALL :
minimizeAll();
break;
case IDM_RESTOREALL :
restoreAll();
break;
case MENU_FILE_OPEN :
handleFileOpen();
break;
case MENU_FILE_SAVEBITMAP :
handleSaveBitmap();
break;
case MENU_FILE_EXIT :
handleExit();
break;
case MENU_SLIDE_SELECT :
handleSlideSelect();
break;
case MENU_TBMESH :
handleMesh();
break;
case MENU_TBNOMESH :
handleNoMesh();
break;
case MENU_TBSIGMA :
handleSigma();
break;
case MENU_TBTRANSFORMA :
handleTransforma();
break;
case MENU_TBTRANSFORMB :
handleTransformb();
break;
case MENU_TBDISSOLVE :
handleCrossDissolve();
break;
case MENU_RESIZE :
handleResize();
break;
case MENU_WARP_CONVEX :
handleWarpConvex();
break;
/* case NNTP_FILE_OPEN :
handleFileOpen();
break;
case NNTP_FILE_BROWSE :
handleFileBrowse();
break;
case NNTP_FILE_EXIT :
FrameWindow::postMessage(*this,WM_CLOSE,0,0L);
break;
case NNTP_NEWS_GETNEWS :
mNewsOption.option((NewsOption::Option)someCallbackData.wParam());
handleRetrieve();
break;
case NNTP_NEWS_GETGROUPS :
mNewsOption.option((NewsOption::Option)someCallbackData.wParam());
handleRetrieve();
break;
case NNTP_NEWSGROUPS_SUBSCRIBE :
handleSubscribe();
break;
case NNTP_IMAGE_FITTOWINDOW :
handleImageFitToWindow();
break;
case NNTP_OPTIONS_NEWSSERVER :
handleNewsServer();
break;
case NNTP_OPTIONS_GENERALOPTIONS :
handleGeneralOptions();
break;
case NNTP_OPTIONS_RASSETTINGS :
handleRasSettings();
break;
case NNTP_OPTIONS_CLEARLOG :
handleClearLog();
break;
case NNTP_NEWS_CANCEL :
handleCancelNews();
break;
case NNTP_VIEW_LOG :
handleViewLog();
break; */
default :
break;
}
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainFrame::keyDownHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainFrame::paintHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainFrame::createHandler(CallbackData &/*someCallbackData*/)
{
createControls();
show(SW_SHOW);
update();
mStatusControl->setText("Ready.");
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainFrame::queryEndSessionHandler(CallbackData &someCallbackData)
{
if(getClient().hasChildren())return (CallbackData::ReturnType)FALSE;
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainFrame::closeHandler(CallbackData &someCallbackData)
{
destroy();
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainFrame::destroyHandler(CallbackData &/*someCallbackData*/)
{
// cancel();
removeHandlers();
::PostQuitMessage(0);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainFrame::sizeHandler(CallbackData &someCallbackData)
{
Rect statusRect;
Rect toolRect;
Rect cRect;
mToolControl->windowRect(toolRect);
mStatusControl->windowRect(statusRect);
cRect.right(someCallbackData.loWord());
cRect.bottom(someCallbackData.hiWord());
getClient().moveWindow(0,toolRect.bottom()-toolRect.top(),cRect.right(),cRect.bottom()-((statusRect.bottom()-statusRect.top())+(toolRect.bottom()-toolRect.top())));
return (CallbackData::ReturnType)FALSE;
}
// **************************************************************************************************
void MainFrame::handleSlideSelect()
{
}
void MainFrame::handleSaveBitmap()
{
}
void MainFrame::handleExit()
{
close();
}
void MainFrame::createControls(void)
{
Rect controlRect;
Rect statusRect;
createToolBar();
mStatusControl=::new StatusBarEx(*this,StatusBarID);
mStatusControl.disposition(PointerDisposition::Delete);
mStatusControl->clientRect(statusRect);
controlRect.bottom(height()/2-statusRect.bottom());
}
void MainFrame::handleFileOpen(void)
{
String strCurrentDirectory;
DiskInfo diskInfo;
BOOL openResult(FALSE);
OpenDialog openFileName;
diskInfo.getCurrentDirectory(strCurrentDirectory);
openFileName.owner(*this);
openFileName.instance(processInstance());
openFileName.filter("Jpg;Gif;Bmp");
openFileName.filterPattern("*.jpg");
openFileName.fileName("*.JPG");
openFileName.fileTitle("");
openFileName.initialDirectory(mLastOpenDirectory.isNull()?strCurrentDirectory:mLastOpenDirectory);
openFileName.title("Open File");
openFileName.creationFlags(OpenDialog::EXPLORER|OpenDialog::FILEMUSTEXIST);
openResult=openFileName.getOpenFileName();
diskInfo.getCurrentDirectory(mLastOpenDirectory);
diskInfo.setCurrentDirectory(strCurrentDirectory);
if(!openResult)return;
openDocument(openFileName.fileName());
}
bool MainFrame::openDocument(const String &strPathFileName)
{
ImageView &imageView=createDocumentView();
imageView.open(strPathFileName);
return false;
}
ImageView &MainFrame::createDocumentView(void)
{
SmartPointer<MDIWindow> mdiWindow;
ImageView *pImageView;
pImageView=::new ImageView;
pImageView->createWindow(*this,String(STRING_DOCUMENTVIEWCLASSNAME),"ImageView","viewMenu","PAINT");
insert(*pImageView);
return *pImageView;
}
void MainFrame::createToolBar(void)
{
mBitmaps.size(10);
mBitmaps[0].loadBitmap("MESH");
mBitmaps[1].loadBitmap("NOMESH");
mBitmaps[2].loadBitmap("SIGMA");
mBitmaps[3].loadBitmap("TRANSFORMA");
mBitmaps[4].loadBitmap("TRANSFORMB");
mBitmaps[5].loadBitmap("XDISSOLVE");
mBitmaps[6].loadBitmap("FILENEW");
mBitmaps[7].loadBitmap("FILEOPEN");
mBitmaps[8].loadBitmap("FILESAVE");
mBitmaps[9].loadBitmap("FILEHELP");
mToolControl=::new ToolBar();
mToolControl.disposition(PointerDisposition::Delete);
mToolControl->create(*this,ToolBarID);
mToolControl->setButtonSize(24,24);
mToolControl->setBitmapSize(22,24);
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[0].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[1].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[2].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[3].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[4].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[5].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[6].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[7].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[8].getHBITMAP(),0));
mToolControl->addBitmap(AddBitmap((UINT)mBitmaps[9].getHBITMAP(),0));
mToolControl->addButton(ToolBarButton(6,0,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(7,MENU_FILE_OPEN,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(8,MENU_FILE_SAVEBITMAP,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(9,0,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(0,MENU_TBMESH,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(1,MENU_TBNOMESH,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(2,MENU_TBSIGMA,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(3,MENU_TBTRANSFORMA,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(4,MENU_TBTRANSFORMB,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(5,MENU_TBDISSOLVE,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->enableButton(MENU_TBMESH,false);
mToolControl->enableButton(MENU_TBNOMESH,false);
mToolControl->enableButton(MENU_TBSIGMA,false);
mToolControl->enableButton(MENU_TBTRANSFORMA,false);
mToolControl->enableButton(MENU_TBTRANSFORMB,false);
mToolControl->enableButton(MENU_TBDISSOLVE,false);
}
void MainFrame::handleResize()
{
SmartPointer<MDIWindow> imageView;
getActive(imageView);
if(!imageView.isOkay())return;
((ImageView&)*imageView).resizeImage();
}
void MainFrame::handleMesh()
{
SmartPointer<MDIWindow> imageView;
getActive(imageView);
if(!imageView.isOkay())return;
((ImageView&)*imageView).showMesh();
}
void MainFrame::handleNoMesh()
{
SmartPointer<MDIWindow> imageView;
getActive(imageView);
if(!imageView.isOkay())return;
((ImageView&)*imageView).noMesh();
}
void MainFrame::handleTransforma()
{
SmartPointer<MDIWindow> imageView;
getActive(imageView);
if(!imageView.isOkay())return;
((ImageView&)*imageView).meshWarp();
}
void MainFrame::handleTransformb()
{
}
void MainFrame::handleSigma()
{
SmartPointer<MDIWindow> imageView;
getActive(imageView);
if(!imageView.isOkay())return;
((ImageView&)*imageView).handleFrames();
}
void MainFrame::handleCrossDissolve()
{
}
void MainFrame::handleWarpConvex(void)
{
PMDIWindow imageView;
getActive(imageView);
if(!imageView.isOkay())return;
((ImageView&)*imageView).handleWarpConvex();
}
// ** virtuals
void MainFrame::mdiDestroy(MDIWindow &mdiWindow)
{
// if(mLogViewWinCache.isOkay()&&*mLogViewWinCache==mdiWindow)mLogViewWinCache.destroy();
}
void MainFrame::mdiActivate(MDIWindow &mdiWindow)
{
mToolControl->enableButton(MENU_TBMESH,true);
mToolControl->enableButton(MENU_TBNOMESH,true);
mToolControl->enableButton(MENU_TBSIGMA,true);
mToolControl->enableButton(MENU_TBTRANSFORMA,true);
mToolControl->enableButton(MENU_TBTRANSFORMB,true);
mToolControl->enableButton(MENU_TBDISSOLVE,true);
}
void MainFrame::mdiDeactivate(MDIWindow &mdiWindow)
{
if(1==size())
{
mToolControl->enableButton(MENU_TBMESH,false);
mToolControl->enableButton(MENU_TBNOMESH,false);
mToolControl->enableButton(MENU_TBSIGMA,false);
mToolControl->enableButton(MENU_TBTRANSFORMA,false);
mToolControl->enableButton(MENU_TBTRANSFORMB,false);
mToolControl->enableButton(MENU_TBDISSOLVE,false);
}
}

89
meshwrp/mainfrm.hpp Normal file
View File

@@ -0,0 +1,89 @@
#ifndef _MESHWRP_MAINWINDOW_HPP_
#define _MESHWRP_MAINWINDOW_HPP_
#ifndef _COMMON_MDIFRM_HPP_
#include <common/mdifrm.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_POINTER_HPP_
#include <common/pointer.hpp>
#endif
#ifndef _COMMON_CALLBACK_HPP_
#include <common/callback.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
#ifndef _COMMON_LINKEDBITMAP_HPP_
#include <common/bmplnk.hpp>
#endif
#ifndef _STATBAR_STATUSBAREX_HPP_
#include <statbar/statbarx.hpp>
#endif
#ifndef _TOOLBAR_TOOLBAR_HPP_
#include <toolbar/toolbar.hpp>
#endif
class ImageView;
class MainFrame : public FrameWindow
{
public:
MainFrame(void);
virtual ~MainFrame();
protected:
virtual void mdiDestroy(MDIWindow &mdiWindow);
virtual void mdiActivate(MDIWindow &mdiWindow);
virtual void mdiDeactivate(MDIWindow &mdiWindow);
private:
enum{StatusBarID=101,ToolBarID=102};
CallbackData::ReturnType closeHandler(CallbackData &someCallbackData);
CallbackData::ReturnType queryEndSessionHandler(CallbackData &someCallbackData);
CallbackData::ReturnType paintHandler(CallbackData &someCallbackData);
CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData);
CallbackData::ReturnType commandHandler(CallbackData &someCallbackData);
CallbackData::ReturnType keyDownHandler(CallbackData &someCallbackData);
CallbackData::ReturnType sizeHandler(CallbackData &someCallbackData);
CallbackData::ReturnType createHandler(CallbackData &someCallbackData);
CallbackData::ReturnType lineHandler(CallbackData &someCallbackData);
bool openDocument(const String &strPathFileName);
ImageView &createDocumentView(void);
void handleFileOpen(void);
void insertHandlers(void);
void removeHandlers(void);
void createControls(void);
void createToolBar(void);
void handleResize(void);
void handleMesh(void);
void handleNoMesh(void);
void handleSigma(void);
void handleTransforma(void);
void handleTransformb(void);
void handleCrossDissolve(void);
void handleWarpConvex(void);
void handleLoadGIF(void);
void handleLoadBitmap(void);
void handleSlideSelect(void);
void handleSaveBitmap(void);
void handleExit(void);
Callback<MainFrame> mPaintHandler;
Callback<MainFrame> mDestroyHandler;
Callback<MainFrame> mCommandHandler;
Callback<MainFrame> mKeyDownHandler;
Callback<MainFrame> mSizeHandler;
Callback<MainFrame> mCreateHandler;
Callback<MainFrame> mCloseHandler;
Callback<MainFrame> mQueryEndSessionHandler;
Callback<MainFrame> mBrowseSelectHandler;
Array<LinkedBitmap> mBitmaps;
SmartPointer<StatusBarEx> mStatusControl;
SmartPointer<ToolBar> mToolControl;
String mLastOpenDirectory;
};
#endif

BIN
meshwrp/mesh.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

495
meshwrp/mesh.cpp Normal file
View File

@@ -0,0 +1,495 @@
#include <mesh/mesh.hpp>
#include <mesh/main.hpp>
#include <common/math.hpp>
#include <common/stdio.hpp>
#include <common/rect.hpp>
#include <common/purehdc.hpp>
char GridMesh::szClassName[]="MESH97A";
char GridMesh::szMenuName[]={'\0'};
GridMesh::GridMesh(HWND hParent,int width,int height,GridShow visibility)
: mhParent(hParent), mStatus(InActive), mGridLines(GridLines),
mIsSuspended(FALSE), mhInstance(::GetModuleHandle(0)),
mDrawingPen(RGBColor(0,0,0),1)
{
mCreateHandler.setCallback(this,&GridMesh::createHandler);
mPaintHandler.setCallback(this,&GridMesh::paintHandler);
mLeftButtonUpHandler.setCallback(this,&GridMesh::leftButtonUpHandler);
mLeftButtonDownHandler.setCallback(this,&GridMesh::leftButtonDownHandler);
mMouseMoveHandler.setCallback(this,&GridMesh::mouseMoveHandler);
mDestroyHandler.setCallback(this,&GridMesh::destroyHandler);
insertHandlers();
mVersionInfo=szClassName;
registerClass();
Rect winRect(CW_USEDEFAULT,CW_USEDEFAULT,width,height);
createWindow(WS_EX_TRANSPARENT,szClassName,String(),WS_CHILD|WS_CLIPSIBLINGS,winRect,mhParent,(HMENU)0,processInstance(),(LPSTR)(Window*)this);
if(GridMesh::Show!=visibility)return;
show(SW_SHOW);
update();
}
GridMesh::~GridMesh()
{
GUIWindow::destroy();
removeHandlers();
}
void GridMesh::insertHandlers(void)
{
insertHandler(VectorHandler::CreateHandler,&mCreateHandler);
insertHandler(VectorHandler::PaintHandler,&mPaintHandler);
insertHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonUpHandler);
insertHandler(VectorHandler::LeftButtonDownHandler,&mLeftButtonDownHandler);
insertHandler(VectorHandler::MouseMoveHandler,&mMouseMoveHandler);
insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
}
void GridMesh::removeHandlers(void)
{
removeHandler(VectorHandler::CreateHandler,&mCreateHandler);
removeHandler(VectorHandler::PaintHandler,&mPaintHandler);
removeHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonUpHandler);
removeHandler(VectorHandler::LeftButtonDownHandler,&mLeftButtonDownHandler);
removeHandler(VectorHandler::MouseMoveHandler,&mMouseMoveHandler);
removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
}
void GridMesh::registerClass(void)
{
WNDCLASS wndClass;
if(::GetClassInfo(mhInstance,szClassName,(WNDCLASS FAR *)&wndClass))return;
wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
wndClass.lpfnWndProc =(WNDPROC)Window::WndProc;
wndClass.cbClsExtra =0;
wndClass.cbWndExtra =sizeof(GridMesh*);
wndClass.hInstance =mhInstance;
wndClass.hIcon =0;
wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW);
wndClass.hbrBackground =(HBRUSH)::GetStockObject(NULL_BRUSH);;
wndClass.lpszMenuName =szMenuName;
wndClass.lpszClassName =szClassName;
::RegisterClass(&wndClass);
}
CallbackData::ReturnType GridMesh::createHandler(CallbackData &/*someCallbackData*/)
{
sendMessage(WM_NCACTIVATE,TRUE,0L);
newMesh();
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType GridMesh::paintHandler(CallbackData &someCallbackData)
{
int segmentCount((int)Array<Segment>::size());
PaintInformation *pPaintInfo=(PaintInformation*)someCallbackData.lParam();
PureDevice &pureDevice=*pPaintInfo;
for(int itemIndex=0;itemIndex<segmentCount;itemIndex++)
(Array<Segment>::operator[](itemIndex)).drawSegment((PureDevice&)*pPaintInfo,mDrawingPen);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType GridMesh::leftButtonUpHandler(CallbackData &someCallbackData)
{
mouseUp(someCallbackData.loWord(),someCallbackData.hiWord());
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType GridMesh::leftButtonDownHandler(CallbackData &someCallbackData)
{
mouseDown(someCallbackData.loWord(),someCallbackData.hiWord());
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType GridMesh::mouseMoveHandler(CallbackData &someCallbackData)
{
mouseMove(someCallbackData.loWord(),someCallbackData.hiWord());
return FALSE;
}
CallbackData::ReturnType GridMesh::destroyHandler(CallbackData &someCallbackData)
{
return (CallbackData::ReturnType)FALSE;
}
void GridMesh::showWindow(int visible)
{
show(visible?SW_SHOW:SW_HIDE);
invalidate();
}
void GridMesh::newMesh(WORD gridLines)
{
createMesh(gridLines,(Array<Segment>&)*this);
::InvalidateRect(mhParent,0,TRUE);
invalidate();
}
void GridMesh::createMesh(WORD gridLines,Array<Segment> &someSegmentVector)
{
RECT clientRect;
WORD xLength;
WORD yLength;
GDIPoint tempFirstPoint;
GDIPoint tempSecondPoint;
WORD vectorSize(0);
Index vectorIndex(0);
if(gridLines>MaxGridLines)mGridLines=GridLines;
else mGridLines=gridLines;
::GetClientRect(*this,(RECT FAR *)&clientRect);
xLength=clientRect.right/(mGridLines+1);
yLength=clientRect.bottom/(mGridLines+1);
for(int x=0,xCount=0;xCount<=mGridLines;x+=xLength,xCount++)
for(int y=0,yCount=0;yCount<=mGridLines;y+=yLength,yCount++)vectorSize+=2;
someSegmentVector.size(vectorSize);
for(x=0,xCount=0;xCount<=mGridLines;x+=xLength,xCount++)
{
for(int y=0,yCount=0;yCount<=mGridLines;y+=yLength,yCount++)
{
tempFirstPoint.setPoint(x+xLength,y+yLength);
tempSecondPoint.setPoint(x+xLength,y);
someSegmentVector[vectorIndex]=Segment(tempFirstPoint,tempSecondPoint,(WORD)vectorIndex);
vectorIndex++;
tempSecondPoint.setPoint(x,y+yLength);
someSegmentVector[vectorIndex]=Segment(tempFirstPoint,tempSecondPoint,(WORD)vectorIndex);
vectorIndex++;
}
}
}
void GridMesh::mouseDown(int x,int y)
{
GDIPoint mousePoint;
size_t size;
if(mIsSuspended)return;
mCurrentIntersection.remove();
mousePoint.setPoint(x,y);
if(!closestIntersection(mCurrentIntersection,mousePoint))
{
mStatus=InActive;
::MessageBeep(-1);
return;
}
mStatus=Active;
PureDevice displayDevice(*this);
size=(int)mCurrentIntersection.size();
for(int i=0;i<size;i++)mCurrentIntersection[i].drawSegment(displayDevice,mDrawingPen);
for(i=0;i<size;i++)mCurrentIntersection[i].drawSegment(displayDevice,mDrawingPen);
}
void GridMesh::mouseMove(int x,int y)
{
GDIPoint mousePoint;
Rect boundingRect;
size_t size;
int index;
if(InActive==mStatus)return;
PureDevice displayDevice(*this);
mousePoint.setPoint(x,y);
size=(int)mCurrentIntersection.size();
getBoundingRect(mCurrentIntersection,boundingRect);
if(!boundingRect.ptInRect(mousePoint))return;
for(index=0;index<size;index++)mCurrentIntersection[index].drawSegment(displayDevice,mDrawingPen);
for(index=0;index<size;index++)mCurrentIntersection[index].firstPoint(mousePoint);
for(index=0;index<size;index++)mCurrentIntersection[index].drawSegment(displayDevice,mDrawingPen);
}
void GridMesh::mouseUp(int x,int y)
{
Rect boundingRect;
GDIPoint swapPoint;
GDIPoint mousePoint;
size_t size;
int index;
if(InActive==mStatus)return;
mStatus=InActive;
mousePoint.setPoint(x,y);
size=(int)mCurrentIntersection.size();
for(index=0;index<size;index++)Array<Segment>::operator[](mCurrentIntersection[index].vectorIndex())=mCurrentIntersection[index];
}
WORD GridMesh::closestIntersection(Block<Segment> &filterBlock,GDIPoint &mousePoint)
{
size_t size((int)Array<Segment>::size());
DWORD tempDistance;
DWORD leastDistance;
Segment tempSegment;
Segment minSegment;
if(!size)return FALSE;
filterBlock.remove();
while(IntersectionSegments!=filterBlock.size())
{
for(int index=0;index<size;index++)
{
if(!index)
{
tempSegment=Array<Segment>::operator[](index);
while(isInBlock(filterBlock,tempSegment))tempSegment=Array<Segment>::operator[](++index);
leastDistance=minDistance(tempSegment,mousePoint);
}
else
{
tempDistance=minDistance(Array<Segment>::operator[](index),mousePoint);
if(tempDistance<leastDistance)
{
minSegment=Array<Segment>::operator[](index);
if(!isInBlock(filterBlock,minSegment))
{
tempSegment=minSegment;
leastDistance=tempDistance;
}
}
}
}
filterBlock.insert(&tempSegment);
}
return orderIntersection(filterBlock);
}
WORD GridMesh::orderIntersection(Block<Segment> &intersection)
{
GDIPoint tempPoint;
GDIPoint swapPoint;
size_t size((int)intersection.size());
int firstSection(0);
int secondSection(0);
int index;
if(IntersectionSegments!=size)return FALSE;
tempPoint=intersection[0].firstPoint();
firstSection=(tempPoint==intersection[1].firstPoint());
if(!firstSection)firstSection=(tempPoint==intersection[1].secondPoint());
if(!firstSection)
{
tempPoint=intersection[0].secondPoint();
secondSection=tempPoint==intersection[1].firstPoint();
if(!secondSection)secondSection=tempPoint==intersection[1].secondPoint();
}
if(!firstSection && !secondSection)return FALSE;
for(index=1;index<size;index++)
{
if(!(tempPoint==intersection[index].firstPoint())&&
!(tempPoint==intersection[index].secondPoint()))return FALSE;
}
if(secondSection)
{
swapPoint=intersection[0].firstPoint();
intersection[0].firstPoint(intersection[0].secondPoint());
intersection[0].secondPoint(swapPoint);
}
for(index=1;index<size;index++)
{
if(!(tempPoint==intersection[index].firstPoint()))
{
intersection[index].secondPoint(intersection[index].firstPoint());
intersection[index].firstPoint(tempPoint);
}
}
return TRUE;
}
WORD GridMesh::isInBlock(Block<Segment> &source,Segment &someSegment)
{
size_t size((int)source.size());
for(int i=0;i<size;i++)if(source[i]==someSegment)return TRUE;
return FALSE;
}
DWORD GridMesh::minDistance(const Segment &someSegment,const GDIPoint &somePoint)
{
LONG yTemp;
LONG xTemp;
LONG midy;
LONG midx;
LONG distancePointOne;
LONG distancePointTwo;
LONG distancePointThree;
yTemp=((LONG)someSegment.yFirst()-(LONG)somePoint.y())*((LONG)someSegment.yFirst()-(LONG)somePoint.y());
xTemp=((LONG)someSegment.xFirst()-(LONG)somePoint.x())*((LONG)someSegment.xFirst()-(LONG)somePoint.x());
distancePointOne=Math::sqrt(int(yTemp+xTemp));
yTemp=((LONG)someSegment.ySecond()-(LONG)somePoint.y())*((LONG)someSegment.ySecond()-(LONG)somePoint.y());
xTemp=((LONG)someSegment.xSecond()-(LONG)somePoint.x())*((LONG)someSegment.xSecond()-(LONG)somePoint.x());
distancePointTwo=Math::sqrt(yTemp+xTemp);
midx=((LONG)someSegment.xFirst()+(LONG)someSegment.xSecond())/2;
midy=((LONG)someSegment.yFirst()+(LONG)someSegment.ySecond())/2;
yTemp=((LONG)midy-(LONG)somePoint.y())*((LONG)midy-(LONG)somePoint.y());
xTemp=((LONG)midx-(LONG)somePoint.x())*((LONG)midx-(LONG)somePoint.x());
distancePointThree=Math::sqrt(yTemp+xTemp);
if(distancePointThree<=distancePointTwo&&distancePointTwo<=distancePointOne)
return distancePointThree;
if(distancePointTwo<=distancePointThree&&distancePointThree<=distancePointOne)
return distancePointTwo;
return distancePointOne;
}
WORD GridMesh::saveMesh(String &pathFileName)
{
FILE *fp;
GDIPoint tempPoint;
size_t size((int)Array<Segment>::size());
if(!size)return FALSE;
if(0==(fp=::fopen((LPSTR)pathFileName,"wb")))return FALSE;
::fwrite((void*)(LPSTR)mVersionInfo,::strlen(mVersionInfo),1,fp);
::fwrite((void*)&size,sizeof(size),1,fp);
::fwrite((void*)&mGridLines,sizeof(mGridLines),1,fp);
for(int i=0;i<size;i++)
{
tempPoint=Array<Segment>::operator[](i).firstPoint();
::fwrite((void *)&tempPoint,sizeof(GDIPoint),1,fp);
tempPoint=Array<Segment>::operator[](i).secondPoint();
::fwrite((void*)&tempPoint,sizeof(Point),1,fp);
}
::fclose(fp);
return TRUE;
}
WORD GridMesh::loadMesh(String &pathFileName)
{
FILE *fp;
GDIPoint firstPoint;
GDIPoint secondPoint;
String versionString;
int vectorIndex(0);
size_t size;
if(0==(fp=::fopen((LPSTR)pathFileName,"rb")))return upgradeStatus(FALSE);
versionString.reserve(String::MaxString);
::fread((void*)(LPSTR)versionString,::strlen(mVersionInfo),1,fp);
if(versionString!=mVersionInfo)
{
::fclose(fp);
return upgradeStatus(FALSE);
}
::fread((void*)&size,sizeof(size),1,fp);
::fread((void*)&mGridLines,sizeof(mGridLines),1,fp);
Array<Segment>::size(size);
for(int i=0;i<size;i++)
{
::fread((void*)&firstPoint,sizeof(Point),1,fp);
::fread((void*)&secondPoint,sizeof(Point),1,fp);
Array<Segment>::operator[](vectorIndex)=Segment(firstPoint,secondPoint,vectorIndex);
vectorIndex++;
}
::fclose(fp);
return upgradeStatus(TRUE);
}
WORD GridMesh::upgradeStatus(WORD retCode)const
{
if(!isVisible())show(SW_SHOW);
::InvalidateRect(mhParent,0,TRUE);
invalidate();
return retCode;
}
WORD GridMesh::retrieveMesh(Array<GDIPoint> &sourcePoints,Array<GDIPoint> &destPoints)
{
Array<Segment> sourceSegments;
createMesh(mGridLines,sourceSegments);
retrieveMesh(sourcePoints,sourceSegments);
retrieveMesh(destPoints,(Array<Segment>&)*this);
if(sourcePoints.size()!=destPoints.size())return FALSE;
return (WORD)sourcePoints.size();
}
WORD GridMesh::retrieveMesh(Array<GDIPoint> &meshPoints,Array<Segment> &someSegmentVector)const
{
Segment tempSegment;
int vectorIndex;
int pointIndex(0);
size_t vectorSize((int)someSegmentVector.size());
int haveFirstColumn(FALSE);
Array<Point> dummyPoint;
meshPoints.size(0);
meshPoints.size((mGridLines+2)*(mGridLines+2));
for(vectorIndex=0;vectorIndex<vectorSize;vectorIndex+=2)
{
if(!(vectorIndex%(mGridLines+1)))
{
if(!vectorIndex&&!haveFirstColumn)meshPoints[pointIndex++]=GDIPoint(0,0);
else if(haveFirstColumn)
{
if(someSegmentVector[vectorIndex].firstPoint().y()<
someSegmentVector[vectorIndex].secondPoint().y())
meshPoints[pointIndex++]=someSegmentVector[vectorIndex].firstPoint();
else
meshPoints[pointIndex++]=someSegmentVector[vectorIndex].secondPoint();
}
}
else if(vectorIndex<=(mGridLines*2)&&!haveFirstColumn)
{
tempSegment=someSegmentVector[vectorIndex-1];
if(tempSegment.firstPoint()==someSegmentVector[vectorIndex].firstPoint()||
tempSegment.firstPoint()==someSegmentVector[vectorIndex].secondPoint())
meshPoints[pointIndex++]=tempSegment.secondPoint();
else
meshPoints[pointIndex++]=tempSegment.firstPoint();
if(vectorIndex==mGridLines*2)
{
if(someSegmentVector[vectorIndex].firstPoint().y()<
someSegmentVector[vectorIndex].secondPoint().y())
meshPoints[pointIndex++]=GDIPoint(0,someSegmentVector[vectorIndex].secondPoint().y());
else
meshPoints[pointIndex++]=GDIPoint(0,someSegmentVector[vectorIndex].firstPoint().y());
}
}
else
{
if(!haveFirstColumn){haveFirstColumn=TRUE;vectorIndex=-2;continue;}
if(someSegmentVector[vectorIndex].firstPoint().y()<
someSegmentVector[vectorIndex].secondPoint().y())
meshPoints[pointIndex++]=someSegmentVector[vectorIndex].firstPoint();
else
meshPoints[pointIndex++]=someSegmentVector[vectorIndex].secondPoint();
if(!((vectorIndex+2)%(mGridLines+1)))
{
if(someSegmentVector[vectorIndex].firstPoint().y()<
someSegmentVector[vectorIndex].secondPoint().y())
meshPoints[pointIndex++]=someSegmentVector[vectorIndex].secondPoint();
else
meshPoints[pointIndex++]=someSegmentVector[vectorIndex].firstPoint();
}
}
}
return (WORD)meshPoints.size();
}
void GridMesh::getBoundingRect(Block<Segment> &currentIntersection,Rect &boundingRect)
{
for(int itemIndex=0;itemIndex<currentIntersection.size();itemIndex++)
{
const GDIPoint &firstPoint=currentIntersection[itemIndex].firstPoint();
const GDIPoint &secondPoint=currentIntersection[itemIndex].secondPoint();
if(!itemIndex)
{
boundingRect.left(firstPoint.x()<secondPoint.x()?firstPoint.x():secondPoint.x());
boundingRect.top(firstPoint.y()<secondPoint.y()?firstPoint.y():secondPoint.y());
boundingRect.right(firstPoint.x()>secondPoint.x()?firstPoint.x():secondPoint.x());
boundingRect.bottom(firstPoint.y()<secondPoint.y()?firstPoint.y():secondPoint.y());
}
else
{
GDIPoint minPoint;
GDIPoint maxPoint;
minPoint.x(firstPoint.x()<secondPoint.x()?firstPoint.x():secondPoint.x());
minPoint.y(firstPoint.y()<secondPoint.y()?firstPoint.y():secondPoint.y());
maxPoint.x(firstPoint.x()>secondPoint.x()?firstPoint.x():secondPoint.x());
maxPoint.y(firstPoint.y()>secondPoint.y()?firstPoint.y():secondPoint.y());
if(minPoint.x()<boundingRect.left())boundingRect.left(minPoint.x());
if(minPoint.y()<boundingRect.top())boundingRect.top(minPoint.y());
if(maxPoint.x()>boundingRect.right())boundingRect.right(maxPoint.x());
if(maxPoint.y()>boundingRect.bottom())boundingRect.bottom(maxPoint.y());
}
}
}

110
meshwrp/mesh.hpp Normal file
View File

@@ -0,0 +1,110 @@
#ifndef _MESHWRP_MESH_HPP_
#define _MESHWRP_MESH_HPP_
#ifndef _COMMON_STDIO_HPP_
#include <common/stdio.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_WINDOW_HPP_
#include <common/window.hpp>
#endif
#ifndef _COMMON_CALLBACK_HPP_
#include <common/callback.hpp>
#endif
#ifndef _COMMON_PEN_HPP_
#include <common/pen.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
#ifndef _MESHWRP_SEGMENT_HPP_
#include <meshwrp/segment.hpp>
#endif
#ifndef _MESHWRP_POLYPOINT_HPP_
#include <meshwrp/polypnt.hpp>
#endif
class GridMesh : public Array<Segment>, public Window
{
public:
enum GridShow{Show,NoShow};
GridMesh(HWND hParent,int width,int height,GridShow visibility=Show);
virtual ~GridMesh(void);
void newMesh(WORD gridLines=GridLines);
WORD saveMesh(String &pathFileName);
WORD loadMesh(String &pathFileName);
WORD retrieveMesh(Array<GDIPoint> &sourcePoints,Array<GDIPoint> &destPoints);
WORD rowCols(void)const;
WORD gridLines(void)const;
WORD upgradeStatus(WORD retCode)const;
// WORD isVisible(void)const;
void showWindow(int visible=TRUE);
void suspendMesh(WORD suspend);
private:
typedef LONG Index;
enum Status{InActive,Active};
enum {IntersectionSegments=4};
enum {GridLines=8,MaxGridLines=16};
void registerClass(void);
long WndProc(UINT message,WPARAM wParam,LPARAM lParam);
void mouseUp(int x,int y);
void mouseDown(int x,int y);
void mouseMove(int x,int y);
DWORD minDistance(const Segment &someSegment,const GDIPoint &mousePoint);
WORD closestIntersection(Block<Segment> &filterSegment,GDIPoint &mousePoint);
WORD orderIntersection(Block<Segment> &intersection);
WORD isInBlock(Block<Segment> &source,Segment &someSegment);
void createMesh(WORD gridLines,Array<Segment> &someSegmentVector);
WORD retrieveMesh(Array<GDIPoint> &meshPoints,Array<Segment> &meshSegments)const;
void getBoundingRect(Block<Segment> &currentIntersection,Rect &boundingRect);
void drawBoundingRect(const Rect &boundingRect);
CallbackData::ReturnType createHandler(CallbackData &someCallbackData);
CallbackData::ReturnType paintHandler(CallbackData &someCallbackData);
CallbackData::ReturnType leftButtonUpHandler(CallbackData &someCallbackData);
CallbackData::ReturnType leftButtonDownHandler(CallbackData &someCallbackData);
CallbackData::ReturnType mouseMoveHandler(CallbackData &someCallbackData);
CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData);
void insertHandlers(void);
void removeHandlers(void);
Callback<GridMesh> mCreateHandler;
Callback<GridMesh> mPaintHandler;
Callback<GridMesh> mLeftButtonUpHandler;
Callback<GridMesh> mLeftButtonDownHandler;
Callback<GridMesh> mMouseMoveHandler;
Callback<GridMesh> mDestroyHandler;
Pen mDrawingPen;
static char szClassName[];
static char szMenuName[];
Block<Segment> mCurrentIntersection;
int mGridLines;
Status mStatus;
String mVersionInfo;
WORD mIsSuspended;
HWND mhParent;
HINSTANCE mhInstance;
};
inline
WORD GridMesh::gridLines(void)const
{
return mGridLines;
}
inline
WORD GridMesh::rowCols(void)const
{
return mGridLines+2;
}
inline
void GridMesh::suspendMesh(WORD suspend)
{
if(suspend)mIsSuspended=TRUE;
else mIsSuspended=FALSE;
}
#endif

BIN
meshwrp/meshwrp.aps Normal file

Binary file not shown.

154
meshwrp/meshwrp.dsp Normal file
View File

@@ -0,0 +1,154 @@
# Microsoft Developer Studio Project File - Name="meshwrp" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=meshwrp - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "meshwrp.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "meshwrp.mak" CFG="meshwrp - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "meshwrp - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "meshwrp - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "meshwrp - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "meshwrp - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "STRICT" /D "__FLAT__" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib comctl32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "meshwrp - Win32 Release"
# Name "meshwrp - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\convex.cpp
# End Source File
# Begin Source File
SOURCE=.\factor.cpp
# End Source File
# Begin Source File
SOURCE=.\framedlg.cpp
# End Source File
# Begin Source File
SOURCE=.\image.cpp
# End Source File
# Begin Source File
SOURCE=.\imageview.cpp
# End Source File
# Begin Source File
SOURCE=.\main.cpp
# End Source File
# Begin Source File
SOURCE=.\mainfrm.cpp
# End Source File
# Begin Source File
SOURCE=.\mesh.cpp
# End Source File
# Begin Source File
SOURCE=.\meshwrp.rc
# End Source File
# Begin Source File
SOURCE=.\polypnt.cpp
# End Source File
# Begin Source File
SOURCE=.\segment.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\944.ICO
# End Source File
# Begin Source File
SOURCE=.\PAINT.ICO
# End Source File
# End Group
# End Target
# End Project

149
meshwrp/meshwrp.dsw Normal file
View File

@@ -0,0 +1,149 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "bsptree"=..\BSPTREE\bsptree.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "common"=..\COMMON\common.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "gif"=..\GIF\gif.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "jpeg6b"="..\..\parts\jpeg-6b\jpeg6b.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "jpgimg"=..\jpgimg\jpgimg.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "meshwrp"=.\meshwrp.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name bsptree
End Project Dependency
Begin Project Dependency
Project_Dep_Name common
End Project Dependency
Begin Project Dependency
Project_Dep_Name statbar
End Project Dependency
Begin Project Dependency
Project_Dep_Name toolbar
End Project Dependency
Begin Project Dependency
Project_Dep_Name gif
End Project Dependency
Begin Project Dependency
Project_Dep_Name jpeg6b
End Project Dependency
Begin Project Dependency
Project_Dep_Name jpgimg
End Project Dependency
Begin Project Dependency
Project_Dep_Name tooltip
End Project Dependency
}}}
###############################################################################
Project: "statbar"=..\STATBAR\Statbar.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "toolbar"=..\TOOLBAR\Toolbar.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "tooltip"=..\TOOLTIP\TOOLTIP.DSP - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

BIN
meshwrp/meshwrp.ncb Normal file

Binary file not shown.

BIN
meshwrp/meshwrp.opt Normal file

Binary file not shown.

43
meshwrp/meshwrp.plg Normal file
View File

@@ -0,0 +1,43 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: statbar - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSPF.tmp" with contents
[
/nologo /Gz /MTd /Zi /Od /D "_DEBUG" /D "__FLAT__" /D "STRICT" /D "WIN32" /D "_WINDOWS" /Fp"\work\exe\msvc42.pch" /YX /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c
"F:\STATBAR\Popup.cpp"
"F:\STATBAR\Statbar.cpp"
"F:\STATBAR\statbarx.cpp"
"F:\STATBAR\Statinfo.cpp"
"F:\STATBAR\statlogo.cpp"
"F:\STATBAR\Statmenu.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSPF.tmp"
Creating command line "link.exe -lib /nologo /out:"..\exe\statbar.lib" .\msvcobj\Popup.obj .\msvcobj\Statbar.obj .\msvcobj\statbarx.obj .\msvcobj\Statinfo.obj .\msvcobj\statlogo.obj .\msvcobj\Statmenu.obj "
<h3>Output Window</h3>
Compiling...
Popup.cpp
F:\STATBAR\Popup.cpp(3) : fatal error C1083: Cannot open precompiled header file: '\work\exe\msvc42.pch': No such file or directory
Statbar.cpp
F:\STATBAR\Statbar.cpp(4) : fatal error C1083: Cannot open precompiled header file: '\work\exe\msvc42.pch': No such file or directory
statbarx.cpp
F:\STATBAR\statbarx.cpp(3) : fatal error C1083: Cannot open precompiled header file: '\work\exe\msvc42.pch': No such file or directory
Statinfo.cpp
F:\STATBAR\Statinfo.cpp(5) : fatal error C1083: Cannot open precompiled header file: '\work\exe\msvc42.pch': No such file or directory
statlogo.cpp
F:\STATBAR\statlogo.cpp(3) : fatal error C1083: Cannot open precompiled header file: '\work\exe\msvc42.pch': No such file or directory
Statmenu.cpp
F:\STATBAR\Statmenu.cpp(5) : fatal error C1083: Cannot open precompiled header file: '\work\exe\msvc42.pch': No such file or directory
Error executing cl.exe.
<h3>Results</h3>
meshwrp.exe - 6 error(s), 0 warning(s)
</pre>
</body>
</html>

448
meshwrp/meshwrp.rc Normal file
View File

@@ -0,0 +1,448 @@
//Microsoft Developer Studio generated resource script.
//
#include "resrc1.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
P944 ICON DISCARDABLE "944.ICO"
PAINT ICON DISCARDABLE "PAINT.ICO"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
ARROWD BITMAP MOVEABLE PURE "ARROWD.BMP"
ARROWL BITMAP MOVEABLE PURE "ARROWL.BMP"
ARROWR BITMAP MOVEABLE PURE "ARROWR.BMP"
ARROWU BITMAP MOVEABLE PURE "ARROWU.BMP"
BLOAD BITMAP MOVEABLE PURE "BLOAD.BMP"
BSAVE BITMAP MOVEABLE PURE "BSAVE.BMP"
CLIP BITMAP MOVEABLE PURE "CLIP.BMP"
CUT BITMAP MOVEABLE PURE "CUT.BMP"
EJECT BITMAP MOVEABLE PURE "EJECT.BMP"
PAUSE BITMAP MOVEABLE PURE "PAUSE.BMP"
PLAY BITMAP MOVEABLE PURE "PLAY.BMP"
VIEW BITMAP MOVEABLE PURE "VIEW.BMP"
TIME BITMAP MOVEABLE PURE "TIME.BMP"
MESH BITMAP MOVEABLE PURE "MESH.BMP"
SIGMA BITMAP MOVEABLE PURE "SIGMA.BMP"
TRANSFORMA BITMAP MOVEABLE PURE "TRANSFORMA.BMP"
TRANSFORMB BITMAP MOVEABLE PURE "TRANSFORMB.BMP"
XDISSOLVE BITMAP MOVEABLE PURE "XDISSOLVE.BMP"
FILENEW BITMAP MOVEABLE PURE "FILENEW.BMP"
FILEOPEN BITMAP MOVEABLE PURE "FILEOPEN.BMP"
FILESAVE BITMAP MOVEABLE PURE "FILESAVE.BMP"
FILEHELP BITMAP MOVEABLE PURE "FILEHELP.BMP"
NOMESH BITMAP MOVEABLE PURE "NOMESH.BMP"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
MDIMAINMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Open...", MENU_FILE_OPEN
MENUITEM "Slide S&how...", MENU_SLIDE_SELECT
MENUITEM "E&xit", MENU_FILE_EXIT
END
END
VIEWMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Open...", MENU_FILE_OPEN
MENUITEM "Slide S&how...", MENU_SLIDE_SELECT
MENUITEM SEPARATOR
MENUITEM "&Save Bitmap...", MENU_FILE_SAVEBITMAP
MENUITEM "E&xit", MENU_FILE_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "Cu&t\tCtrl+X", MENU_CUT
MENUITEM "&Copy\tCtrl+C", MENU_COPY
MENUITEM "P&aste\tCtrl+V", MENU_PASTE
MENUITEM "Cli&p\tCtrl+P", MENU_CLIP
END
POPUP "E&nhancement"
BEGIN
MENUITEM "&Smoothing", MENU_SMOOTHING
MENUITEM "&Resize", MENU_RESIZE
MENUITEM "&Translate", MENU_TRANSLATE
MENUITEM "S&hear", MENU_SHEAR
END
POPUP "War&ping"
BEGIN
MENUITEM "&Perspective Warp", MENU_WARP_PERSPECTIVE
MENUITEM "&Convex Warp", MENU_WARP_CONVEX
END
POPUP "Pale&tte"
BEGIN
MENUITEM "&View Palette...", MENU_PALETTE_VIEW
END
POPUP "&Window"
BEGIN
MENUITEM "&Cascade\tShift+F5", IDM_CASCADE
MENUITEM "&Tile\tShift+F4", IDM_TILE
MENUITEM "&Arrange &icons", IDM_ARRANGE
MENUITEM "&Hide Toolbar", IDM_TOOLBAR
MENUITEM SEPARATOR
MENUITEM "Close &all", IDM_CLOSEALL
MENUITEM "Mi&nimize all", IDM_MINIMIZEALL
MENUITEM "&Restore all", IDM_RESTOREALL
END
END
SLIDEMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Open...", MENU_FILE_OPEN
MENUITEM "Slide S&how...", MENU_SLIDE_SELECT
MENUITEM SEPARATOR
MENUITEM "&Save Bitmap...", MENU_FILE_SAVEBITMAP
MENUITEM "E&xit", MENU_FILE_EXIT
END
POPUP "&Window"
BEGIN
MENUITEM "&Cascade\tShift+F5", IDM_CASCADE
MENUITEM "&Tile\tShift+F4", IDM_TILE
MENUITEM "&Arrange &icons", IDM_ARRANGE
MENUITEM "&Hide Toolbar", IDM_TOOLBAR
MENUITEM SEPARATOR
MENUITEM "Close &all", IDM_CLOSEALL
MENUITEM "Mi&nimize all", IDM_MINIMIZEALL
MENUITEM "&Restore all", IDM_RESTOREALL
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
FILESELECT DIALOG DISCARDABLE 31, 27, 211, 145
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 6, "Helv"
BEGIN
LISTBOX IDS_FLIST,5,53,201,88,LBS_SORT | LBS_USETABSTOPS |
WS_VSCROLL | WS_TABSTOP
EDITTEXT IDS_FNAME,42,6,84,12,ES_AUTOHSCROLL
CONTROL "Ok",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,131,3,36,24
CONTROL "Cancel",IDCANCEL,"Button",BS_OWNERDRAW | WS_TABSTOP,170,
3,36,24
LTEXT "File Name:",-1,2,8,38,8
LTEXT "Path:",-1,4,24,17,8
LTEXT "",IDS_FPATH,25,24,98,9
LTEXT "File",-1,20,38,16,8
LTEXT "Date",-1,68,38,16,8
LTEXT "Size",-1,129,38,16,8
LTEXT "Time",-1,159,38,16,8
LTEXT "File Save",IDS_FILESAVE,90,155,38,8
LTEXT "File Open",IDS_FILEOPEN,90,168,34,8
END
VIEWSELECT DIALOG DISCARDABLE 11, 26, 130, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Mesh Target"
FONT 6, "Helv"
BEGIN
CONTROL "Cancel",IDCANCEL,"Button",BS_OWNERDRAW | WS_TABSTOP,92,
5,36,24
LISTBOX VIEWSEL_LIST,5,4,82,48,LBS_SORT | LBS_USETABSTOPS |
WS_VSCROLL
END
PROCESSING DIALOG DISCARDABLE 20, 36, 153, 190
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Image Processing"
FONT 6, "Helv"
BEGIN
CHECKBOX "3x3 Matrix Averaging",IP_AVERAGING,7,55,82,12
CHECKBOX "Low Pass Filter",IP_LOWPASS,7,70,77,12
CHECKBOX "High Pass Filter",IP_HIGHPASS,7,85,65,12
EDITTEXT IP_33R1C1,104,57,14,12
EDITTEXT IP_33R1C2,118,57,14,12
EDITTEXT IP_33R1C3,132,57,14,12
EDITTEXT IP_33R2C1,104,69,14,12
EDITTEXT IP_33R2C2,118,69,14,12
EDITTEXT IP_33R2C3,132,69,14,12
EDITTEXT IP_33R3C1,104,81,14,12
EDITTEXT IP_33R3C2,118,81,14,12
EDITTEXT IP_33R3C3,132,81,14,12
CHECKBOX "Sobel Transform",IP_SOBEL,7,124,87,12
CHECKBOX "Smoothed Transform",IP_SMOOTHED,7,136,84,12
CHECKBOX "Laplace Transform",IP_LAPLACE,7,148,80,12
CHECKBOX "Isotropic Transform",IP_ISOTROPIC,7,160,75,12
CHECKBOX "Stochastic Transform",IP_STOCHASTIC,7,172,85,12
CONTROL "Ok",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,77,2,36,24
CONTROL "Cancel",IDCANCEL,"Button",BS_OWNERDRAW | WS_TABSTOP,115,
2,36,24
GROUPBOX "Smoothing Algorithms",IP_SMOOTHING,3,37,148,68
LTEXT "Matrix",-1,109,47,24,7
GROUPBOX "Edge Detection Algorithms",IP_EDGE,3,111,148,76
END
SLIDESHOW DIALOG DISCARDABLE 20, 30, 208, 128
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Slide Show"
FONT 6, "Helv"
BEGIN
CONTROL "Ok",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,132,4,36,24
CONTROL "Cancel",IDCANCEL,"Button",BS_OWNERDRAW | WS_TABSTOP,169,
4,36,24
RADIOBUTTON "Select Files",SS_SELECT,5,29,51,12,WS_TABSTOP
END
FACTOR DIALOG DISCARDABLE 10, 27, 90, 72
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 6, "Helv"
BEGIN
EDITTEXT FACTOR_WIDTH,56,40,32,12
EDITTEXT FACTOR_HEIGHT,56,54,32,12
EDITTEXT FACTOR_WIDTHINCR,140,40,40,12
EDITTEXT FACTOR_HEIGHTINCR,140,54,40,12
RADIOBUTTON "Op :",FACTOR_WIDTHOP,182,41,28,12,WS_TABSTOP
RADIOBUTTON "Op :",FACTOR_HEIGHTOP,182,54,27,12,WS_TABSTOP
PUSHBUTTON "Ok",IDOK,1,1,36,24
PUSHBUTTON "Cancel",IDCANCEL,40,1,36,24
LTEXT "Width Factor :",-1,4,42,48,8
LTEXT "Height Factor :",-1,4,55,51,8
LTEXT "Incremental :",-1,93,42,45,8
LTEXT "Incremental :",-1,93,55,44,8
LTEXT "",FACTOR_WOPSTRING,211,43,9,8
LTEXT "",FACTOR_HOPSTRING,211,55,9,8
END
FRAME DIALOG DISCARDABLE 10, 27, 172, 77
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Mesh Frames"
FONT 6, "Helv"
BEGIN
LTEXT "Number of Frames:",-1,4,45,67,8
EDITTEXT FRAME_FRAMES,70,43,37,12
PUSHBUTTON "Ok",IDOK,114,4,50,14
PUSHBUTTON "Cancel",IDCANCEL,114,19,50,14
END
PALETTE DIALOG DISCARDABLE 30, 0, 142, 105
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Palette"
FONT 6, "Helv"
BEGIN
CONTROL "",PALETTE_COLORS,"Button",BS_OWNERDRAW,1,34,140,68
CONTROL "Ok",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,103,3,36,24
END
DISSOLVE DIALOG DISCARDABLE 19, 25, 143, 137
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Cross Dissolve Schedule"
FONT 6, "Helv"
BEGIN
LISTBOX DSLV_LIST,3,54,137,79,LBS_HASSTRINGS | LBS_USETABSTOPS |
WS_VSCROLL | WS_TABSTOP
CONTROL "",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,105,2,36,24
CONTROL "",IDCANCEL,"Button",BS_OWNERDRAW | WS_TABSTOP,68,2,36,
24
LTEXT "Frame",-1,5,42,20,8
LTEXT "Source",-1,36,42,26,8
LTEXT "Repeat",-1,102,42,25,8
LTEXT "Destination",-1,62,42,38,8
END
EDITDISSOLVE DIALOG DISCARDABLE 21, 35, 117, 74
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Edit Item"
FONT 8, "Helv"
BEGIN
LTEXT "Source :",-1,4,39,29,8
LTEXT "Destination :",-1,4,51,45,8
LTEXT "Repeat :",-1,4,63,34,8
EDITTEXT EDITITEM_SOURCE,50,35,32,12
EDITTEXT EDITITEM_DESTINATION,50,47,32,12
EDITTEXT EDITITEM_REPEAT,50,59,16,12
CONTROL "",IDOK,"Button",BS_OWNERDRAW | WS_TABSTOP,80,2,36,24
CONTROL "",IDCANCEL,"Button",BS_OWNERDRAW | WS_TABSTOP,43,2,36,
24
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
MDIACCEL ACCELERATORS MOVEABLE PURE
BEGIN
VK_F5, IDM_CASCADE, VIRTKEY, SHIFT
VK_F4, IDM_TILE, VIRTKEY, SHIFT
"X", MENU_CUT, VIRTKEY, CONTROL
"C", MENU_COPY, VIRTKEY, CONTROL
"V", MENU_PASTE, VIRTKEY, CONTROL
"P", MENU_CLIP, VIRTKEY, CONTROL
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resrc1.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""resource.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
"FRAME", DIALOG
BEGIN
RIGHTMARGIN, 81
BOTTOMMARGIN, 65
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
STRING_HIDETOOLBAR "&Hide Toolbar"
STRING_SHOWTOOLBAR "&Show Toolbar"
STRING_ASTERISKDOTBMP "*.BMP"
STRING_ASTERISKDOTGIF "*.GIF"
STRING_BITMAPOKFOCUSUP "OKFOCUSUP"
STRING_BITMAPOKNOFUP "OKNOFUP"
STRING_BITMAPOKFOCUSDN "OKFOCUSDN"
STRING_BITMAPCAFOCUSUP "CAFOCUSUP"
STRING_BITMAPCANOFUP "CANOFUP"
STRING_BITMAPCAFOCUSDN "CAFOCUSDN"
STRING_LITERALCLIP "CLIP"
STRING_LITERALMESH "MESH"
STRING_LITERALCUT "CUT"
STRING_LITERALARROWD "ARROWD"
STRING_LITERALARROWU "ARROWU"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_PROJECTEXTENSION ".PRJ"
STRING_DOT "."
STRING_CRLF "\n"
STRING_ASTERISKDOTPRJ "*.PRJ"
STRING_PROJECTIDSTRING "PRJV1.00"
STRING_UNKNOWNFILETYPE "Dont know how to handle this file."
STRING_UNKNOWNREFERENCE "Project references missing or invalid items."
STRING_ERRORLOADINGPRJ "Error loading project"
STRING_LITERALSIGMA "SIGMA"
STRING_INIFILENAME "MDIWIN.INI"
STRING_UNSET "UNSET"
STRING_INISETTINGS "SETTINGS"
STRING_INIPROJDIR "ProjDir"
STRING_INIMESHDIR "MeshDir"
STRING_TABSTRING "\t"
STRING_LITERALDISSOLVE "XDISSOLVE"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_LITERALARROWR "ARROWR"
STRING_LITERALARROWL "ARROWL"
STRING_LITERALTEST "TEST"
STRING_LITERALBSAVE "BSAVE"
STRING_LITERALBLOAD "BLOAD"
STRING_LITERALTRANSFORMA "TRANSFORMA"
STRING_LITERALTRANSFORMB "TRANSFORMB"
STRING_LITERALVIEW "VIEW"
STRING_LITERALTIME "TIME"
STRING_LITERALPLAY "PLAY"
STRING_LITERALPAUSE "PAUSE"
STRING_LITERALEJECT "EJECT"
STRING_LITERALTOOLBAR "ToolBar"
STRING_LITERAL944 "P944"
STRING_MESHEXTENSION ".000"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_APPNAME "MeshWarp"
STRING_APPVERSION "1.0"
STRING_DOCUMENTVIEWCLASSNAME "ImageView"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

BIN
meshwrp/mot.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

BIN
meshwrp/nomesh.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/pause.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/play.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

6
meshwrp/polypnt.cpp Normal file
View File

@@ -0,0 +1,6 @@
#include <mesh/polypnt.hpp>
PolyPoint::PolyPoint(const PolyPoint &somePolyPoint)
{
for(int pointIndex=0;pointIndex<MaxPoint;pointIndex++)mPolyPoint[pointIndex]=somePolyPoint.mPolyPoint[pointIndex];
}

35
meshwrp/polypnt.hpp Normal file
View File

@@ -0,0 +1,35 @@
#ifndef _MESHWRP_POLYPOINT_HPP_
#define _MESHWRP_POLYPOINT_HPP_
#ifndef _COMMON_GDIPOINT_HPP_
#include <common/gdipoint.hpp>
#endif
class PolyPoint
{
public:
enum {MaxPoint=4};
PolyPoint(void);
PolyPoint(const PolyPoint &somePolyPoint);
virtual ~PolyPoint();
GDIPoint &operator[](unsigned point);
private:
GDIPoint mPolyPoint[MaxPoint];
};
inline
PolyPoint::PolyPoint(void)
{
}
inline
PolyPoint::~PolyPoint()
{
}
inline
GDIPoint &PolyPoint::operator[](unsigned point)
{
if(point>=MaxPoint)return mPolyPoint[MaxPoint-1];
return mPolyPoint[point];
}
#endif

166
meshwrp/pwarp.cpp Normal file
View File

@@ -0,0 +1,166 @@
#include <meshwrp/pwarp.hpp>
PerspectiveWarp::PerspectiveWarp()
: mWidth(0), mHeight(0), mwRow(0), mwCol(0), mWarpType(Incremental), mColOp(Add), mRowOp(Add), mRowIncr(0), mColIncr(0)
{
}
/*PerspectiveWarp::PerspectiveWarp(WORD width,WORD height,UHUGE *hpImageInvert,double wRow,double wCol)
: mWidth(width), mHeight(height),mwRow(wRow), mwCol(wCol),
mhpImageInvert(hpImageInvert), mWarpType(None),
mIsInThread(TRUE)
{
}
PerspectiveWarp::PerspectiveWarp(WORD width,WORD height,double wRow,double wCol,Operation colOp,double colIncr,Operation rowOp,double rowIncr,UHUGE *hpImageInvert)
: mWidth(width), mHeight(height), mwRow(wRow), mwCol(wCol),
mColOp(colOp), mColIncr(colIncr), mRowOp(rowOp), mRowIncr(rowIncr),
mhpImageInvert(hpImageInvert), mWarpType(Incremental),
mIsInThread(TRUE)
{
}
*/
PerspectiveWarp::~PerspectiveWarp()
{
}
Image PerspectiveWarp::performPerspectiveWarp(Image &image,double wRow,double wCol,Operation colOp,double colIncr,Operation rowOp,double rowIncr)
{
mWidth=image.width();
mHeight=image.height();
mwRow=wRow;
mwCol=wCol;
mColOp=colOp;
mRopOp=rowOp;
mColIncr=colIncr;
mRowIncr=rowIncr;
return Image();
}
/* HGLOBAL PerspectiveWarp::performPerspectiveWarp(void)
{
if(Incremental==mWarpType)return incrementalWarp();
return nonIncrementalWarp();
} */
HGLOBAL PerspectiveWarp::incrementalWarp(void)
{
int maxCol, maxRow;
double newRow, newCol, tempColFactor, tempRowFactor;
LONG rowMult, colMult, row, col;
HGLOBAL hGlobal, hGlobalTemp, hGlobalSource;
UHUGE *ptr;
UHUGE *ptrSource;
maxCol=maxRow=0L;
hGlobalSource=Main::upsideDown(mWidth,mHeight,mhpImageInvert);
ptrSource=(UHUGE*)::GlobalLock(hGlobalSource);
hGlobal=::GlobalAlloc(GMEM_FIXED,(LONG)mHeight*(LONG)mWidth);
ptr=(UHUGE*)::GlobalLock(hGlobal);
Main::hmemset(ptr,0,(LONG)mHeight*(LONG)mWidth);
tempRowFactor=mwRow;
for(row=0;row<mHeight;row++)
{
tempColFactor=mwCol;
for(col=0;col<mWidth;col++)
{
newCol=(col/((mwCol*col)+(mwRow*row)+1))+.5;
newRow=(row/((mwCol*col)+(mwRow*row)+1))+.5;
if(newRow>maxRow)maxRow=(int)newRow;
if(newCol>maxCol)maxCol=(int)newCol;
if(Add==mColOp)mwCol+=mColIncr;
else if(Subtract==mColOp)mwCol=(mwCol-mColIncr<0?0:mwCol-mColIncr);
else if(Multiply==mColOp)mwCol*=mColIncr;
else mwCol/=(mColIncr?mColIncr:1);
if(!yieldTask())return (HGLOBAL)emergencyCleanup(hGlobalSource,hGlobal);
}
mwCol=tempColFactor;
if(Add==mRowOp)mwRow+=mRowIncr;
else if(Subtract==mRowOp)mwRow=(mwRow-mRowIncr<0?0:mwRow-mRowIncr);
else if(Multiply==mRowOp)mwRow*=mRowIncr;
else mwRow/=(mRowIncr?mRowIncr:1);
}
rowMult=(mHeight/(maxRow?maxRow:1));
colMult=(mWidth/(maxCol?maxCol:1));
mwRow=tempRowFactor;
for(row=0;row<mHeight;row++)
{
tempColFactor=mwCol;
for(col=0;col<mWidth;col++)
{
newCol=((col/((mwCol*col)+(mwRow*row)+1)))*rowMult;
newRow=((row/((mwCol*col)+(mwRow*row)+1)))*colMult;
if(((LONG)newRow*(LONG)mWidth)+(LONG)newCol>=(LONG)mWidth*(LONG)mHeight)
continue;
*(ptr+((LONG)newRow*(LONG)mWidth)+(LONG)newCol)=
*(ptrSource+(row*(LONG)mWidth)+col);
if(Add==mColOp)mwCol+=mColIncr;
else if(Subtract==mColOp)mwCol=(mwCol-mColIncr<0?0:mwCol-mColIncr);
else if(Multiply==mColOp)mwCol*=mColIncr;
else mwCol/=(mColIncr?mColIncr:1);
if(!yieldTask())return (HGLOBAL)emergencyCleanup(hGlobalSource,hGlobal);
}
mwCol=tempColFactor;
if(Add==mRowOp)mwRow+=mRowIncr;
else if(Subtract==mRowOp)mwRow=(mwRow-mRowIncr<0?0:mwRow-mRowIncr);
else if(Multiply==mRowOp)mwRow*=mRowIncr;
else mwRow/=(mRowIncr?mRowIncr:1);
}
::GlobalUnlock(hGlobalSource);
::GlobalFree(hGlobalSource);
hGlobalTemp=Main::upsideDown(mWidth,mHeight,ptr);
::GlobalUnlock(hGlobal);
::GlobalFree(hGlobal);
return hGlobalTemp;
}
HGLOBAL PerspectiveWarp::nonIncrementalWarp(void)
{
int maxCol, maxRow;
double newRow, newCol;
LONG rowMult, colMult, row, col;
HGLOBAL hGlobal, hGlobalTemp, hGlobalSource;
UHUGE *ptr;
UHUGE *ptrSource;
maxCol=maxRow=0L;
hGlobalSource=Main::upsideDown(mWidth,mHeight,mhpImageInvert);
ptrSource=(UHUGE*)::GlobalLock(hGlobalSource);
hGlobal=::GlobalAlloc(GMEM_FIXED,(LONG)mHeight*(LONG)mWidth);
ptr=(UHUGE*)::GlobalLock(hGlobal);
Main::hmemset(ptr,0,(LONG)mHeight*(LONG)mWidth);
for(row=0;row<mHeight;row++)
{
for(col=0;col<mWidth;col++)
{
newCol=(col/((mwCol*col)+(mwRow*row)+1))+.5;
newRow=(row/((mwCol*col)+(mwRow*row)+1))+.5;
if(newRow>maxRow)maxRow=(int)newRow;
if(newCol>maxCol)maxCol=(int)newCol;
if(!yieldTask())return (HGLOBAL)emergencyCleanup(hGlobalSource,hGlobal);
}
}
rowMult=(mHeight/(maxRow?maxRow:1));
colMult=(mWidth/(maxCol?maxCol:1));
for(row=0;row<mHeight;row++)
{
for(col=0;col<mWidth;col++)
{
newCol=((col/((mwCol*col)+(mwRow*row)+1)))*rowMult;
newRow=((row/((mwCol*col)+(mwRow*row)+1)))*colMult;
if(((LONG)newRow*(LONG)mWidth)+(LONG)newCol>=(LONG)mWidth*(LONG)mHeight)
continue;
*(ptr+((LONG)newRow*(LONG)mWidth)+(LONG)newCol)=
*(ptrSource+(row*(LONG)mWidth)+col);
if(!yieldTask())return (HGLOBAL)emergencyCleanup(hGlobalSource,hGlobal);
}
}
::GlobalUnlock(hGlobalSource);
::GlobalFree(hGlobalSource);
hGlobalTemp=Main::upsideDown(mWidth,mHeight,ptr);
::GlobalUnlock(hGlobal);
::GlobalFree(hGlobal);
return hGlobalTemp;
}

31
meshwrp/pwarp.hpp Normal file
View File

@@ -0,0 +1,31 @@
#ifndef _MESHWRP_PERSPECTIVEWARP_HPP_
#define _MESHWRP_PERSPECTIVEWARP_HPP_
//#include <mdiwin/main.hpp>
class PerspectiveWarp
{
public:
enum Type{Incremental,None};
enum Operation{Add,Subtract,Multiply,Divide};
PerspectiveWarp(void);
// PerspectiveWarp(WORD width,WORD height,UHUGE *hpImageInvert,double wRow,double wCol);
// PerspectiveWarp(WORD width,WORD height,double wRow,double wCol,Operation colOp,double colIncr,Operation rowOp,double rowIncr,UHUGE *hpImageInvert);
virtual ~PerspectiveWarp();
// Image performPerspectiveWarp(Image &image,double wRow,double wCol,Operation colOp,double colIncr,Operation rowOp,double rowIncr);
// HGLOBAL performPerspectiveWarp(void);
private:
HGLOBAL incrementalWarp(void);
HGLOBAL nonIncrementalWarp(void);
double mwRow;
double mwCol;
double mRowIncr;
double mColIncr;
Operation mRowOp;
Operation mColOp;
WORD mWidth;
WORD mHeight;
Type mWarpType;
UHUGE *mhpImageInvert;
};
#endif

162
meshwrp/resource.h Normal file
View File

@@ -0,0 +1,162 @@
#ifndef _MESHWRP_RESOURCE_H_
#define _MESHWRP_RESOURCE_H_
#define EDITITEM_SOURCE 102
#define EDITITEM_DESTINATION 103
#define EDITITEM_REPEAT 104
// defines for dissolve schedule dialog
#define DSLV_LIST 101
// defines for ViewSelect Dialog
#define VIEWSEL_LIST 101
// defines for FrameDialog
#define FRAME_FRAMES 101
// defines for Main Menu
#define MENU_FILE_OPEN 0x01
#define MENU_FILE_EXIT 0x03
#define MENU_PALETTE_VIEW 0x04
#define MENU_CUT 0x05
#define MENU_COPY 0x06
#define MENU_PASTE 0x07
#define MENU_SMOOTHING 0x08
#define MENU_RESIZE 0x09
#define MENU_TRANSLATE 0x0A
#define MENU_WARP_PERSPECTIVE 0x0B
#define MENU_CLIP 0x0C
#define MENU_FILE_SAVEBITMAP 0x0D
#define MENU_SHEAR 0x0E
#define MENU_WARP_CONVEX 0x10
#define MENU_TBMESH 0x20
#define MENU_TBCLIP 0x21
#define MENU_TBARROWL 0x23
#define MENU_TBARROWR 0x24
#define MENU_TBARROWU 0x25
#define MENU_TBARROWD 0x26
#define MENU_TBSAVE 0x27
#define MENU_TBLOAD 0x28
#define MENU_TBTRANSFORMA 0x29
#define MENU_TBTRANSFORMB 0x2A
#define MENU_TBSIGMA 0x2B
#define MENU_TBPLAY 0x2C
#define MENU_TBEJECT 0x2D
#define MENU_TBPAUSE 0x2E
#define MENU_TBTIME 0x2F
#define MENU_SLIDE_SELECT 0x30
#define MENU_TBDISSOLVE 0x31
#define MENU_TBNOMESH 0x32
// defines for file selection dialog
#define IDS_FLIST 0x0B
#define IDS_FNAME 0x0C
#define IDS_FPATH 0x0D
#define IDS_FILEOPEN 0x0E
#define IDS_FILESAVE 0x0F
// defines for factor dialog window
#define FACTOR_WIDTH 101
#define FACTOR_HEIGHT 102
#define FACTOR_WIDTHINCR 103
#define FACTOR_HEIGHTINCR 104
#define FACTOR_WIDTHOP 105
#define FACTOR_HEIGHTOP 106
#define FACTOR_WOPSTRING 107
#define FACTOR_HOPSTRING 108
// defines for enhancement dialog
#define IP_SMOOTHING 104
#define IP_EDGE 114
#define IP_SMDEFAULTS 120
#define IP_AVERAGING 101
#define IP_LOWPASS 102
#define IP_HIGHPASS 103
#define IP_33R1C1 105
#define IP_33R1C2 106
#define IP_33R1C3 107
#define IP_33R2C1 108
#define IP_33R2C2 109
#define IP_33R2C3 110
#define IP_33R3C1 111
#define IP_33R3C2 112
#define IP_33R3C3 113
#define IP_SOBEL 115
#define IP_SMOOTHED 116
#define IP_LAPLACE 117
#define IP_ISOTROPIC 118
#define IP_STOCHASTIC 119
// defines for palette dialog
#define PALETTE_COLORS 101
// defines for slide select dialog
#define SS_LIST 101
#define SS_SELECT 102
#define SS_BMP 103
#define SS_PROJECT 104
// defines for string table
#define STRING_HIDETOOLBAR 0x0001
#define STRING_SHOWTOOLBAR 0x0002
#define STRING_ASTERISKDOTBMP 0x0003
#define STRING_ASTERISKDOTGIF 0x0004
#define STRING_BITMAPOKFOCUSUP 0x0005
#define STRING_BITMAPOKNOFUP 0x0006
#define STRING_BITMAPOKFOCUSDN 0x0007
#define STRING_BITMAPCAFOCUSUP 0x0008
#define STRING_BITMAPCANOFUP 0x0009
#define STRING_BITMAPCAFOCUSDN 0x000A
#define STRING_LITERALCLIP 0x000B
#define STRING_LITERALMESH 0x000C
#define STRING_LITERALCUT 0x000D
#define STRING_LITERALARROWD 0x000E
#define STRING_LITERALARROWU 0x000F
#define STRING_LITERALARROWR 0x0010
#define STRING_LITERALARROWL 0x0011
#define STRING_LITERALTEST 0x0012
#define STRING_LITERALBSAVE 0x0013
#define STRING_LITERALBLOAD 0x0014
#define STRING_LITERALTRANSFORMA 0x0015
#define STRING_LITERALTRANSFORMB 0x0016
#define STRING_LITERALVIEW 0x0017
#define STRING_LITERALTIME 0x0018
#define STRING_LITERALPLAY 0x0019
#define STRING_LITERALSTOP 0x001A
#define STRING_LITERALPAUSE 0x001B
#define STRING_LITERALEJECT 0x001C
#define STRING_LITERALTOOLBAR 0x001D
#define STRING_LITERAL944 0x001E
#define STRING_MESHEXTENSION 0x001F
#define STRING_PROJECTEXTENSION 0x0020
#define STRING_DOT 0x0021
#define STRING_CRLF 0x0022
#define STRING_ASTERISKDOTPRJ 0x0023
#define STRING_PROJECTIDSTRING 0x0024
#define STRING_UNKNOWNFILETYPE 0x0025
#define STRING_UNKNOWNREFERENCE 0x0026
#define STRING_ERRORLOADINGPRJ 0x0027
#define STRING_LITERALSIGMA 0x0028
#define STRING_INIFILENAME 0x0029
#define STRING_UNSET 0x002A
#define STRING_INISETTINGS 0x002B
#define STRING_INIPROJDIR 0x002C
#define STRING_INIMESHDIR 0x002D
#define STRING_TABSTRING 0x002E
#define STRING_LITERALDISSOLVE 0x002F
#define STRING_APPNAME 0x0030
#define STRING_APPVERSION 0x0031
#define STRING_DOCUMENTVIEWCLASSNAME 0x0032
#define IDM_CASCADE 10014
#define IDM_TILE 10015
#define IDM_ARRANGE 10016
#define IDM_CLOSEALL 10017
#define IDM_MINIMIZEALL 10018
#define IDM_RESTOREALL 10019
#define IDM_TOOLBAR 10020
#endif

4
meshwrp/resource.hpp Normal file
View File

@@ -0,0 +1,4 @@
#ifndef _MESHWRP_RESOURCE_HPP_
#define _MESHWRP_RESOURCE_HPP_
#include <meshwrp/resource.h>
#endif

16
meshwrp/resrc1.h Normal file
View File

@@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by meshwrp.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

42
meshwrp/scraps.txt Normal file
View File

@@ -0,0 +1,42 @@
void ImageView::createToolBar(void)
{
/* Block<AddBitmap> addBitmaps;
mToolControl=::new ToolBar();
mToolControl.disposition(PointerDisposition::Delete);
mToolControl->create(*this,101);
addBitmaps.insert(&AddBitmap(0,HINST_COMMCTRL));
if(!mToolControl->addBitmaps(addBitmaps))return;
// mToolControl->addButton(ToolBarButton(STD_FILENEW,MenuFileNew,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(STD_FILEOPEN,MENU_FILE_OPEN,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
mToolControl->addButton(ToolBarButton(STD_FILESAVE,500,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
// mToolControl->addButton(ToolBarButton(STD_PRINT,500,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
// mToolControl->addButton(ToolBarButton(STD_CUT,500,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
// mToolControl->addButton(ToolBarButton(STD_COPY,500,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
// mToolControl->addButton(ToolBarButton(STD_PASTE,500,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
// mToolControl->addButton(ToolBarButton(STD_FIND,500,ToolBarButton::StateEnabled,ToolBarButton::StyleButton));
// mToolControl->addButton(ToolBarButton(STD_PRINT,500,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); */
}
PureToolInfo pureToolInfo;
Rect itemRect;
// mToolControl->getItemRect(0,itemRect);
clientRect(itemRect);
pureToolInfo.flags(PureToolInfo::None);
// pureToolInfo.hwnd(*mToolControl);
pureToolInfo.hwnd(getClient());
// pureToolInfo.resInst(processInstance());
pureToolInfo.rect(itemRect);
pureToolInfo.szText("This is an edit control.");
mToolTipControl->addTool(pureToolInfo);
SmartPointer<ToolTip> mToolTipControl;
mToolTipControl=::new ToolTip(*this);
mToolTipControl.disposition(PointerDisposition::Delete);

362
meshwrp/scroll.hpp Normal file
View File

@@ -0,0 +1,362 @@
#ifndef _MESHWRP_SCROLLINFO_HPP_
#define _MESHWRP_SCROLLINFO_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
class ScrollInfo
{
public:
ScrollInfo(void);
ScrollInfo(const ScrollInfo &someScrollInfo);
virtual ~ScrollInfo();
ScrollInfo &operator=(const ScrollInfo &someScrollInfo);
BOOL operator==(const ScrollInfo &someScrollInfo)const;
void handleHorizontalScroll(CallbackData &someCallbackData);
void handleVerticalScroll(CallbackData &someCallbackData);
void handleSize(CallbackData &someCallbackData);
int minScrollx(void)const;
void minScrollx(int minScrollx);
int maxScrollx(void)const;
void maxScrollx(int maxScrollx);
int currScrollx(void)const;;
void currScrollx(int currScrollx);
int minScrolly(void)const;
void minScrolly(int minScrolly);
int maxScrolly(void)const;
void maxScrolly(int maxScrolly);
int currScrolly(void)const;
void currScrolly(int curScrolly);
void scrollableObjectDimensions(int width,int height);
int scrollableObjectWidth(void)const;
int scrollableObjectHeight(void)const;
BOOL scrollEvent(void)const;
void scrollEvent(BOOL scrollEvent);
BOOL sizeEvent(void)const;
void sizeEvent(BOOL sizeEvent);
HWND hwndOwner(void)const;
void hwndOwner(HWND hwndOwner);
private:
void scrollableObjectWidth(int scrollableObjectWidth);
void scrollableObjectHeight(int scrollableObjectHeight);
enum{PageIncrement=50,LineIncrement=5};
int imax(int param1,int param2);
int imin(int param1,int param2);
HWND mhWndOwner;
BOOL mSizeEvent;
BOOL mScrollEvent;
int mScrollableObjectWidth;
int mScrollableObjectHeight;
int mMinScrollx;
int mMaxScrollx;
int mCurrScrollx;
int mMinScrolly;
int mMaxScrolly;
int mCurrScrolly;
};
inline
ScrollInfo::ScrollInfo(void)
: mMinScrollx(0), mMaxScrollx(0), mCurrScrollx(0), mMinScrolly(0), mMaxScrolly(0), mCurrScrolly(0),
mScrollableObjectWidth(0), mScrollableObjectHeight(0), mSizeEvent(FALSE), mhWndOwner(0), mScrollEvent(FALSE)
{
}
inline
ScrollInfo::ScrollInfo(const ScrollInfo &someScrollInfo)
{
*this=someScrollInfo;
}
inline
ScrollInfo::~ScrollInfo()
{
}
inline
ScrollInfo &ScrollInfo::operator=(const ScrollInfo &someScrollInfo)
{
minScrollx(someScrollInfo.minScrollx());
maxScrollx(someScrollInfo.maxScrollx());
currScrollx(someScrollInfo.currScrollx());
maxScrolly(someScrollInfo.currScrolly());
minScrolly(someScrollInfo.maxScrolly());
currScrolly(someScrollInfo.minScrollx());
sizeEvent(someScrollInfo.minScrollx());
scrollEvent(someScrollInfo.scrollEvent());
scrollableObjectWidth(someScrollInfo.scrollableObjectWidth());
scrollableObjectHeight(someScrollInfo.scrollableObjectHeight());
hwndOwner(someScrollInfo.hwndOwner());
return *this;
}
inline
BOOL ScrollInfo::operator==(const ScrollInfo &someScrollInfo)const
{
return (minScrollx()==someScrollInfo.minScrollx()&&
maxScrollx()==someScrollInfo.maxScrollx()&&
currScrollx()==someScrollInfo.currScrollx()&&
minScrolly()==someScrollInfo.minScrolly()&&
maxScrolly()==someScrollInfo.maxScrolly()&&
currScrolly()==someScrollInfo.currScrolly()&&
sizeEvent()==someScrollInfo.sizeEvent()&&
scrollEvent()==someScrollInfo.scrollEvent()&&
scrollableObjectWidth()==someScrollInfo.scrollableObjectWidth()&&
scrollableObjectHeight()==someScrollInfo.scrollableObjectHeight()&&
hwndOwner()==someScrollInfo.hwndOwner());
}
inline
int ScrollInfo::minScrollx(void)const
{
return mMinScrollx;
}
inline
void ScrollInfo::minScrollx(int minScrollx)
{
mMinScrollx=minScrollx;
}
inline
int ScrollInfo::maxScrollx(void)const
{
return mMaxScrollx;
}
inline
void ScrollInfo::maxScrollx(int maxScrollx)
{
mMaxScrollx=maxScrollx;
}
inline
int ScrollInfo::currScrollx(void)const
{
return mCurrScrollx;
}
inline
void ScrollInfo::currScrollx(int currScrollx)
{
mCurrScrollx=currScrollx;
}
inline
int ScrollInfo::minScrolly(void)const
{
return mMinScrolly;
}
inline
void ScrollInfo::minScrolly(int minScrolly)
{
mMinScrolly=minScrolly;
}
inline
int ScrollInfo::maxScrolly(void)const
{
return mMaxScrolly;
}
inline
void ScrollInfo::maxScrolly(int maxScrolly)
{
mMaxScrolly=maxScrolly;
}
inline
int ScrollInfo::currScrolly(void)const
{
return mCurrScrolly;
}
inline
void ScrollInfo::currScrolly(int currScrolly)
{
mCurrScrolly=currScrolly;
}
inline
BOOL ScrollInfo::scrollEvent(void)const
{
return mScrollEvent;
}
inline
void ScrollInfo::scrollEvent(BOOL scrollEvent)
{
mScrollEvent=scrollEvent;
}
inline
BOOL ScrollInfo::sizeEvent(void)const
{
return mSizeEvent;
}
inline
void ScrollInfo::sizeEvent(BOOL sizeEvent)
{
mSizeEvent=sizeEvent;
}
inline
void ScrollInfo::scrollableObjectDimensions(int width,int height)
{
RECT clientRect;
scrollableObjectWidth(width);
scrollableObjectHeight(height);
sizeEvent(FALSE);
scrollEvent(FALSE);
::GetClientRect(hwndOwner(),&clientRect);
handleSize(CallbackData(0,MAKELPARAM(clientRect.right,clientRect.bottom)));
}
inline
int ScrollInfo::scrollableObjectWidth(void)const
{
return mScrollableObjectWidth;
}
inline
void ScrollInfo::scrollableObjectWidth(int scrollableObjectWidth)
{
mScrollableObjectWidth=scrollableObjectWidth;
}
inline
int ScrollInfo::scrollableObjectHeight(void)const
{
return mScrollableObjectHeight;
}
inline
void ScrollInfo::scrollableObjectHeight(int scrollableObjectHeight)
{
mScrollableObjectHeight=scrollableObjectHeight;
}
inline
HWND ScrollInfo::hwndOwner(void)const
{
return mhWndOwner;
}
inline
void ScrollInfo::hwndOwner(HWND hwndOwner)
{
mhWndOwner=hwndOwner;
}
inline
void ScrollInfo::handleHorizontalScroll(CallbackData &someCallbackData)
{
int xDelta;
int yDelta;
int xNew;
yDelta=0;
switch(LOWORD(someCallbackData.wParam()))
{
case SB_PAGEUP :
xNew=currScrollx()-PageIncrement;
break;
case SB_PAGEDOWN :
xNew=currScrollx()+PageIncrement;
break;
case SB_LINEUP :
xNew=currScrollx()-LineIncrement;
break;
case SB_LINEDOWN :
xNew=currScrollx()+LineIncrement;
break;
case SB_THUMBPOSITION :
xNew= HIWORD(someCallbackData.wParam());
break;
default :
xNew=currScrollx();
break;
}
xNew=imax(0,xNew);
xNew=imin(maxScrollx(),xNew);
if(xNew==currScrollx())return;
scrollEvent(TRUE);
xDelta=xNew-currScrollx();
currScrollx(xNew);
::ScrollWindow(hwndOwner(),-xDelta,-yDelta,(const RECT*)0,(const RECT*)0);
::UpdateWindow(hwndOwner());
::SetScrollPos(hwndOwner(),SB_HORZ,currScrollx(),TRUE);
}
inline
void ScrollInfo::handleVerticalScroll(CallbackData &someCallbackData)
{
int yDelta;
int yNew;
int xDelta;
xDelta=0;
switch(LOWORD(someCallbackData.wParam()))
{
case SB_PAGEUP :
yNew=currScrolly()-PageIncrement;
break;
case SB_PAGEDOWN :
yNew=currScrolly()+PageIncrement;
break;
case SB_LINEUP :
yNew=currScrolly()-LineIncrement;
break;
case SB_LINEDOWN :
yNew=currScrolly()+LineIncrement;
break;
case SB_THUMBPOSITION :
yNew=HIWORD(someCallbackData.wParam());
break;
default :
yNew=currScrolly();
break;
}
yNew=imax(0,yNew);
yNew=imin(maxScrolly(),yNew);
if(yNew==currScrolly())return;
scrollEvent(TRUE);
yDelta=yNew-currScrolly();
currScrolly(yNew);
::ScrollWindow(hwndOwner(),-xDelta,-yDelta,(const RECT*)0,(const RECT*)0);
::UpdateWindow(hwndOwner());
::SetScrollPos(hwndOwner(),SB_VERT,currScrolly(),TRUE);
}
inline
void ScrollInfo::handleSize(CallbackData &someCallbackData)
{
int xNew(someCallbackData.loWord());
int yNew(someCallbackData.hiWord());
sizeEvent(TRUE);
maxScrollx(imax(scrollableObjectWidth()-xNew,0));
::SetScrollRange(hwndOwner(),SB_HORZ,minScrollx(),maxScrollx(),FALSE);
currScrollx(imin(currScrollx(),maxScrollx()));
::SetScrollPos(hwndOwner(),SB_HORZ,currScrollx(),TRUE);
maxScrolly(imax(scrollableObjectHeight()-yNew,0));
::SetScrollRange(hwndOwner(),SB_VERT,minScrolly(),maxScrolly(),FALSE);
currScrolly(imin(currScrolly(),maxScrolly()));
::SetScrollPos(hwndOwner(),SB_VERT,currScrolly(),TRUE);
}
inline
int ScrollInfo::imax(int param1,int param2)
{
return param1>param2?param1:param2;
}
inline
int ScrollInfo::imin(int param1,int param2)
{
return param1<param2?param1:param2;
}
#endif

56
meshwrp/segment.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include <mesh/segment.hpp>
#include <common/array.hpp>
#include <common/purehdc.hpp>
Segment::Segment()
{
}
Segment::~Segment()
{
}
Segment::Segment(const GDIPoint &firstPoint,const GDIPoint &secondPoint,WORD vectorIndex)
{
mFirstPoint=firstPoint;
mSecondPoint=secondPoint;
mVectorIndex=vectorIndex;
}
Segment::Segment(const Segment &someSegment)
{
mFirstPoint=someSegment.mFirstPoint;
mSecondPoint=someSegment.mSecondPoint;
mVectorIndex=someSegment.mVectorIndex;
}
WORD Segment::operator==(const Segment &someSegment)const
{
return ((mFirstPoint==someSegment.mFirstPoint &&
mSecondPoint==someSegment.mSecondPoint)||
(mFirstPoint==someSegment.mSecondPoint &&
mSecondPoint==someSegment.mFirstPoint));
}
void Segment::operator=(const Segment &someSegment)
{
mFirstPoint=someSegment.mFirstPoint;
mSecondPoint=someSegment.mSecondPoint;
mVectorIndex=someSegment.mVectorIndex;
}
void Segment::drawSegment(PureDevice &displayDevice,HPEN hPen,bool setROP)const
{
GDIPoint currentPosition;
HPEN hOldPen(0);
int saveMode;
if(setROP)saveMode=::SetROP2(displayDevice,R2_NOT);
if(hPen)hOldPen=(HPEN)::SelectObject(displayDevice,hPen);
::GetCurrentPositionEx(displayDevice,(POINT FAR*)&currentPosition);
::MoveToEx(displayDevice,mFirstPoint.x(),mFirstPoint.y(),(POINT FAR*)&currentPosition);
::LineTo(displayDevice,mSecondPoint.x(),mSecondPoint.y());
::MoveToEx(displayDevice,currentPosition.x(),currentPosition.y(),(POINT FAR*)&mSecondPoint);
if(hOldPen)::SelectObject(displayDevice,hOldPen);
if(setROP)::SetROP2(displayDevice,saveMode);
}

97
meshwrp/segment.hpp Normal file
View File

@@ -0,0 +1,97 @@
#ifndef _MESHWRP_SEGMENT_HPP_
#define _MESHWRP_SEGMENT_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_GDIPOINT_HPP_
#include <common/gdipoint.hpp>
#endif
class PureDevice;
class Segment
{
public:
Segment(void);
Segment(const GDIPoint &firstPoint,const GDIPoint &secondPoint,WORD vectorIndex);
Segment(const Segment &someSegment);
virtual ~Segment(void);
WORD operator==(const Segment &someSegment)const;
void operator=(const Segment &someSegment);
void drawSegment(PureDevice &displayDevice,HPEN hPen=0,bool setROP=true)const;
WORD vectorIndex(void)const;
WORD xFirst(void)const;
WORD xSecond(void)const;
WORD yFirst(void)const;
WORD ySecond(void)const;
const GDIPoint &firstPoint(void)const;
const GDIPoint &secondPoint(void)const;
void firstPoint(const GDIPoint &somePoint);
void secondPoint(const GDIPoint &somePoint);
GDIPoint leadingPoint(void)const;
private:
GDIPoint mFirstPoint;
GDIPoint mSecondPoint;
WORD mVectorIndex;
};
inline
WORD Segment::xFirst(void)const
{
return mFirstPoint.x();
}
inline
WORD Segment::xSecond(void)const
{
return mSecondPoint.x();
}
inline
WORD Segment::yFirst(void)const
{
return mFirstPoint.y();
}
inline
WORD Segment::ySecond(void)const
{
return mSecondPoint.y();
}
inline
const GDIPoint &Segment::firstPoint(void)const
{
return mFirstPoint;
}
inline
const GDIPoint &Segment::secondPoint(void)const
{
return mSecondPoint;
}
inline
void Segment::firstPoint(const GDIPoint &somePoint)
{
mFirstPoint=somePoint;
}
inline
void Segment::secondPoint(const GDIPoint &somePoint)
{
mSecondPoint=somePoint;
}
inline
GDIPoint Segment::leadingPoint(void)const
{
return (mFirstPoint.y()<mSecondPoint.y()?mSecondPoint:mFirstPoint);
}
inline
WORD Segment::vectorIndex(void)const
{
return mVectorIndex;
}
#endif

BIN
meshwrp/sigma.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/time.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/transforma.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/transformb.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/vgany3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
meshwrp/view.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

BIN
meshwrp/xdissolve.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B