home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mandelc.zip / apfel.h < prev    next >
C/C++ Source or Header  |  1993-08-01  |  6KB  |  199 lines

  1. #ifndef MENUPMPROCESS_H
  2. #define MENUPMPROCESS_H
  3.  
  4. #define INCL_PM
  5. #define INCL_GPIBITMAPS
  6. #define INCL_DOSNMPIPES
  7. #define INCL_DOSMODULEMGR
  8. extern "C"
  9. {
  10. #include <memory.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. };
  14. #include "pmProcess.h"
  15. #include "string.h"
  16. #include "calcFractal.h"
  17. #include "apfel.resource.h"
  18. #include "communication.h"
  19.  
  20.  
  21. class menuPmThread;
  22. class menuWindowTree;
  23. class menuPmProcess;
  24. class calcThread;
  25. class clientThread;
  26. class pipeName;
  27.  
  28.  
  29. // Mandelbrot calculating window
  30. class menuWindowTree:public processWindow
  31. {       public:
  32.     // Pointer to function which will be used for iteration method
  33.     pFctCalculateFractal pFctCalculate;
  34.     unsigned int iIdSelected;
  35.     // number of pixels
  36.     int iSizeX, iSizeY;
  37.     //HDC hdc;
  38.     HDC hdcBitmap;
  39.     HPS hpsBitmap;
  40.     HBITMAP hbm;
  41.     // to make shure, that only one thread accesses the next two variables
  42.     mtxObject oMtx;
  43.     // array of Booleans, which line is already calculated
  44.     unsigned char *pabCalculated;
  45.     // which line is the next for the next free server
  46.     unsigned int iLine;
  47.     // if this is true, the window has been started with coordinates
  48.     // from a zoom - the coordinates will not be initialized in one
  49.     // the initPre() or initPost() function
  50.     Boolean bCoordiantesValid;    // Are the following Values valid
  51.     // xdx is the x value difference between two horizontal pixels
  52.     // ydx is the y value difference between two horizontal pixels
  53.     // The absolute difference between two pixels is always
  54.     // the same for both horizontal or vertical pixels
  55.     // The x value difference between two vertical pixels is -ydx
  56.     // The y value difference between two vertical pixels is xdx
  57.     // dLimit is the absolute value^2 of the complex value pair (x,y)
  58.     // which must be reached
  59.     double xa, ya, xdx, ydx, dLimit;
  60.     unsigned int eZoomState;
  61.     //    0 means no valid zoom
  62.     //    1 means first point selected
  63.     //    2 has already moved, still moving
  64.     //    3 means second point selected,
  65.     int iZoomXA, iZoomYA, iZoomXE, iZoomYE;
  66.     unsigned int iMaxIterations, iMaxColors;
  67.     HPS hZoomRectanglePS;
  68.     HWND hwndMenu;
  69.     void winInvalidate(unsigned int yi);
  70.     virtual void doPaint(HPS hps, RECTL *pStructRectl);
  71.     virtual void destructPre(void);
  72.     void drawZoomRectangle(void);
  73.     //calcThread *pCalcThread;
  74.     menuPmProcess *pProcess;
  75.     menuPmThread *pMsgThread;
  76.     //animateThread *pAnimateThread;
  77.     //fullScreen *pFullScreen;
  78.     virtual MRESULT windowProc(ULONG msg, MPARAM mp1, MPARAM mp2);
  79.     menuWindowTree(menuPmThread *pMsgThreadNew, int idResource,
  80.         char *pTitle);
  81.     virtual ~menuWindowTree(void);
  82.     virtual Boolean initPost(void);
  83.     virtual Boolean initPre(void);
  84.     void calcZoomCoordinates(void);
  85.     Boolean startCalculation(void);
  86.     void stopCalculation(void);
  87. };
  88.  
  89.  
  90. class settingsDlg:public dlgWindow
  91. {    public:
  92.     menuWindowTree *pParent;
  93.     char *pStrXa, *pStrXe, *pStrYa, *pStrYe, *pStrLimit;
  94.     settingsDlg(menuWindowTree *pParentNew);
  95.     virtual ~settingsDlg(void);
  96.     virtual MRESULT DIDOK(MPARAM mp2);
  97.     virtual Boolean initPost(void);
  98. };
  99. // this thread does the calculation of the mandelbrot set in one window
  100. class calcThread:public pmWindowThread
  101. {       public:
  102.     //menuPmThread *pMsgThread;
  103.     menuWindowTree *pWindow;
  104.     //calcThread(menuPmThread *pParentNew);
  105.     calcThread(menuWindowTree *pWindowNew);
  106.     inline void winInvalidate(unsigned int yi);
  107.     //virtual ~calcThread(void);
  108.     virtual void doSomething(void);
  109. };
  110.  
  111.  
  112. // a thread which sends requests to the server and wait for the replies
  113. // There is one such thread for every server available
  114. class clientThread:public pmWindowThread
  115. {    public:
  116.     // handle for pipe to server
  117.     HPIPE hPipe;
  118.     char *pPipeName;
  119.     menuWindowTree *pWindow;
  120.     clientThread(menuWindowTree *pWindowNew, char *pPipeName);
  121.     virtual ~clientThread(void);
  122.     virtual void doSomething(void);
  123. };
  124.  
  125.  
  126. // The message thread
  127. #define idGetChainElementMenuMsgThreadTreeThis \
  128.     (idGetChainElementPmMsgThreadTreeLast + 1)
  129. class menuPmThread:public pmMsgThread
  130. {       public:
  131.     menuPmProcess *pProcess;
  132.     menuPmThread(menuPmProcess *pProcess);
  133.     virtual Boolean create(void);
  134.     //virtual Boolean initPost(void);
  135.     virtual void *getChainElementMember(unsigned int iMsg)
  136.     {    switch (iMsg)
  137.         {    default:
  138.                 return pmMsgThread::getChainElementMember(iMsg);
  139.             case idGetChainElementMenuMsgThreadTreeThis:
  140.                 return (void*)this;
  141.         }
  142.     }
  143. };
  144.  
  145.  
  146. // This class will be called, to create threads for all serves
  147. // which are available.
  148. // See implementation of toBeCalledForeachElement
  149. // The parent of such element is menuPmProcess.chainPipes
  150. #define idForeachPipeNameMakeThread (idForeachStringChainElementLast + 1)
  151. class pipeName:public stringChainElement
  152. {    public:
  153.     pipeName(char *pString, chain *pParent)
  154.         :stringChainElement(pString, pParent)
  155.     {
  156.     }
  157.     virtual int toBeCalledForeachElement(unsigned int iMsg, void *pDummy);
  158. };
  159.  
  160.  
  161. #define idForeachDLLNameAddMenuEntry (idForeachStringChainElementLast + 1)
  162. #define idForeachDLLNameGetThisByIndex (idForeachStringChainElementLast + 2)
  163. class dLLName:public stringChainElement
  164. {    public:
  165.     pFctCalculateFractal pFctCalculate;
  166.     char *pDescription;
  167.     unsigned int iId;
  168.     HMODULE hDLL;
  169.     dLLName(char *pString, chain *pParent, unsigned int iMenuIdNew);
  170.     virtual ~dLLName(void);
  171.     virtual int toBeCalledForeachElement(unsigned int iMsg, void *pDummy);
  172. };
  173.  
  174.  
  175. // The process
  176. class menuPmProcess:public pmProcess
  177. {       public:
  178.     // contains objects of type stringChainElement
  179.     // This are names of pipes provided by servers for calculating
  180.     // on all machines available.
  181.     // This names will be read from a file. The name of the file
  182.     // should be passed on the commandline!
  183.     // You should start on every OS/2 machine in the net
  184.     // a server by passing a unique pipe name.
  185.     // A pipe name must include the prefix "\pipe\".
  186.     chain chainPipes;
  187.     chain chainDLLNames;
  188.     virtual Boolean create(void);
  189.     menuPmProcess(int argc, char **argv)
  190.         :pmProcess(argc, argv),
  191.         chainPipes(),
  192.         chainDLLNames()
  193.     {
  194.     }
  195. };
  196.  
  197.  
  198. #endif !MENUPMPROCESS_H
  199.