home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mandlcpp.zip / apfel.h < prev    next >
C/C++ Source or Header  |  1993-06-27  |  5KB  |  163 lines

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