Ignore:
Timestamp:
08/04/04 16:50:27 (20 years ago)
Author:
merck
Message:
MMerck: Changes to handle display of laser spot in button bitmaps.
MMerck: New bitmaps and masks added.
Location:
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/mirrorselector.cpp

    r3401 r4492  
    3636#include "threadcontroller.h"
    3737
    38 #define MASKFILENAME  "/home/amc/share/amc/TypeMask.xbm"
    39 #define TYPE0FILENAME "/home/amc/share/amc/Type0Mirror.xbm"
    40 #define TYPE1FILENAME "/home/amc/share/amc/Type1Mirror.xbm"
    41 #define TYPE2FILENAME "/home/amc/share/amc/Type2Mirror.xbm"
    42 #define TYPE3FILENAME "/home/amc/share/amc/Type3Mirror.xbm"
    43 #define TYPE4FILENAME "/home/amc/share/amc/Type4Mirror.xbm"
    44 #define TYPE5FILENAME "/home/amc/share/amc/Type5Mirror.xbm"
    45 #define TYPE6FILENAME "/home/amc/share/amc/Type6Mirror.xbm"
     38#define MASKFILENAME  "/home/amc/AMC/share/amc/TypeMask.xbm"
     39#define TYPE0FILENAME "/home/amc/AMC/share/amc/Type0Mirror.xbm"
     40#define TYPE1FILENAME "/home/amc/AMC/share/amc/Type1Mirror.xbm"
     41#define TYPE2FILENAME "/home/amc/AMC/share/amc/Type2Mirror.xbm"
     42#define TYPE3FILENAME "/home/amc/AMC/share/amc/Type3Mirror.xbm"
     43#define TYPE4FILENAME "/home/amc/AMC/share/amc/Type4Mirror.xbm"
     44#define TYPE5FILENAME "/home/amc/AMC/share/amc/Type5Mirror.xbm"
     45#define TYPE6FILENAME "/home/amc/AMC/share/amc/Type6Mirror.xbm"
     46
     47#define TYPE1LFILENAME "/home/amc/AMC/share/amc/Type1MirrorLas.xpm"
     48#define TYPE2LFILENAME "/home/amc/AMC/share/amc/Type2MirrorLas.xpm"
     49#define TYPE3LFILENAME "/home/amc/AMC/share/amc/Type3MirrorLas.xpm"
     50#define TYPE4LFILENAME "/home/amc/AMC/share/amc/Type4MirrorLas.xpm"
     51#define TYPE5LFILENAME "/home/amc/AMC/share/amc/Type5MirrorLas.xpm"
     52#define TYPE6LFILENAME "/home/amc/AMC/share/amc/Type6MirrorLas.xpm"
     53
     54#define TYPE1LMFILENAME "/home/amc/AMC/share/amc/Type1MirrorLas.xbm"
     55#define TYPE2LMFILENAME "/home/amc/AMC/share/amc/Type2MirrorLas.xbm"
     56#define TYPE3LMFILENAME "/home/amc/AMC/share/amc/Type3MirrorLas.xbm"
     57#define TYPE4LMFILENAME "/home/amc/AMC/share/amc/Type4MirrorLas.xbm"
     58#define TYPE5LMFILENAME "/home/amc/AMC/share/amc/Type5MirrorLas.xbm"
     59#define TYPE6LMFILENAME "/home/amc/AMC/share/amc/Type6MirrorLas.xbm"
    4660
    4761#define MAX(a,b) ((a>b) ? a : b )
     
    5569        QBitmap theMask( MASKFILENAME );
    5670       
    57         QPixmap* pixType[7];
    58         pixType[0] = new QPixmap( TYPE0FILENAME );
    59         pixType[1] = new QPixmap( TYPE1FILENAME );
    60         pixType[2] = new QPixmap( TYPE2FILENAME );
    61         pixType[3] = new QPixmap( TYPE3FILENAME );
    62         pixType[4] = new QPixmap( TYPE4FILENAME );
    63         pixType[5] = new QPixmap( TYPE5FILENAME );
    64         pixType[6] = new QPixmap( TYPE6FILENAME );
     71        m_pixType[0] = new QPixmap( TYPE0FILENAME );
     72        m_pixType[1] = new QPixmap( TYPE1FILENAME );
     73        m_pixType[2] = new QPixmap( TYPE2FILENAME );
     74        m_pixType[3] = new QPixmap( TYPE3FILENAME );
     75        m_pixType[4] = new QPixmap( TYPE4FILENAME );
     76        m_pixType[5] = new QPixmap( TYPE5FILENAME );
     77        m_pixType[6] = new QPixmap( TYPE6FILENAME );
     78
     79        m_pixType[7] = new QPixmap( TYPE1LFILENAME );
     80        m_pixType[8] = new QPixmap( TYPE2LFILENAME );
     81        m_pixType[9] = new QPixmap( TYPE3LFILENAME );
     82        m_pixType[10] = new QPixmap( TYPE4LFILENAME );
     83        m_pixType[11] = new QPixmap( TYPE5LFILENAME );
     84        m_pixType[12] = new QPixmap( TYPE6LFILENAME );
     85
     86        m_bitMask[0] = new QBitmap( TYPE1LMFILENAME );
     87        m_bitMask[1] = new QBitmap( TYPE2LMFILENAME );
     88        m_bitMask[2] = new QBitmap( TYPE3LMFILENAME );
     89        m_bitMask[3] = new QBitmap( TYPE4LMFILENAME );
     90        m_bitMask[4] = new QBitmap( TYPE5LMFILENAME );
     91        m_bitMask[5] = new QBitmap( TYPE6LMFILENAME );
     92
     93  m_pixType[7]->setMask( *m_bitMask[0]);
     94  m_pixType[8]->setMask( *m_bitMask[1]);
     95  m_pixType[9]->setMask( *m_bitMask[2]);
     96  m_pixType[10]->setMask( *m_bitMask[3]);
     97  m_pixType[11]->setMask( *m_bitMask[4]);
     98  m_pixType[12]->setMask( *m_bitMask[5]);
     99
    65100        // Check if we found the files with the pixmaps
    66         for(int i=0; i<7; i++)
     101        for(int i=0; i<13; i++)
    67102        {
    68                 if( pixType[i]->isNull() )
     103                if( m_pixType[i]->isNull() )
    69104                {
    70105       
     
    72107                                                "Can't open PIXMAP files for buttons",
    73108                                                                "The programm didn't find the files \'Type?Mirror.xbm\'\n"
    74                                                                 "We expect this file in the directory \'/home/amc/share/amc\'\n",
     109                                                                "We expect this file in the directory \'/home/amc/AMC/share/amc\'\n",
    75110                                                                "Quit" );
    76111                        exit(-1);                                                                       
     
    120155            m_mirrorButton[i+8][j+8] = pButton;
    121156            pButton->setFlat( true );
    122             pButton->setFlat( true );
    123157            pButton->setMinimumSize( QSize( 30, 30 ) );
    124158            pButton->setMaximumSize( QSize( 50, 50 ) );
     
    129163                  AMCMirrorPanel* thePanel = g_theMirror->panelAt( j+8, i+8 );
    130164                  int type = thePanel->type();
    131                         pButton->setPixmap( *pixType[type] );
     165                        pButton->setPixmap( *m_pixType[type] );
    132166                        if( type == 0)
    133167                        pButton->setEnabled( false );
     
    149183                }
    150184        }               
     185        m_pSelectedButton = 0;
    151186        connect( this, SIGNAL(clicked(int)), SLOT(buttonSelectedSlot(int)) );
    152187
     
    155190MirrorSelector::~MirrorSelector()
    156191{
     192        for(int i=0; i<13; i++)
     193        {
     194                delete m_pixType[i];
     195    m_pixType[i] = NULL;
     196  }
     197        for(int i=0; i<6; i++)
     198        {
     199                delete m_bitMask[i];
     200    m_bitMask[i] = NULL;
     201  }
    157202}
    158203
     
    163208        int j = -1 * ((index / 17) - 8);
    164209        AMCMirrorPanel* pPanel = g_theMirror->panelAt( i+8, j+8 );
     210        QButton* pButton = m_mirrorButton[j+8][i+8];
     211        if( m_pSelectedButton )
     212                m_pSelectedButton->setBackgroundMode( QWidget::PaletteBackground );
     213
     214        pButton->setBackgroundMode( QWidget::PaletteMid );
     215        m_pSelectedButton = pButton;
    165216        emit panelSelectedSignal( pPanel );
    166217
    167218}
    168 /** No descriptions */
    169 /*
    170 void MirrorSelector::saveMirrorPanels()
    171 {
    172         QCString line;
    173        
    174         QFile file( POSFILENAME );
    175         if( file.open( IO_WriteOnly ) )
    176         {
    177                 QTextStream stream( &file );
    178                 for(int j=0; j<17; j++)
    179                 {
    180                         line.sprintf("# Column %d\n",j-8);
    181                         stream << line;
    182                         for(int i=0; i<17; i++)
    183                         {
    184                                 line.sprintf(" %2d %2d\t%4d\t%4d\n",
    185                                 m_Panel[i][j]->i(),
    186                                 m_Panel[i][j]->j(),
    187                                 m_Panel[i][j]->getX(),
    188                                 m_Panel[i][j]->getY() );
    189                                 stream << line;
    190                         }
    191                 }
    192                                        
    193         }
    194         else
    195         {
    196                 int iRes = QMessageBox::critical( this,
    197                                                                                  "Can't open panel position description file",
    198                                                                                  "The programm tried to open the file \'PanelPos.txt\'\n"
    199                                                                                  "in the directory \'/home/amc/\'.\n"
    200                                                                                  "The file may not have the right permissions.\n",
    201                                                                                  "Continue" );
    202         }
    203         file.close();
    204                                        
    205 }
    206 */
    207 /** Read he panel descriptions from the file "Panels.txt".
    208         This file contains for each panel a line with the following contents:
    209         i       j       type    port    box             driver  installed
    210        
    211         i: is the first panel index (counting from left to right)
    212         j: is the second panel index (counting from bottom to top)
    213         type: the panel type (see the file for a description of types)
    214         port: the serial port this box is connected to.
    215                   (The numbering corresponds to the numbers on the cables.
    216                    If only 1 Meilhaus ME8100 card is installed on linux boxes
    217                    we have the following correspondance to device files
    218                    port 1 == /dev/ttyS4 ... port 8 = /dev/ttyS11)
    219         box: the number of the AMC box.
    220         driver: The internal AMC driver to which this panel is connected.
    221         installed: Flag indicating if this panel is installed (0=no, 1=yes)
    222 */
    223 /*
    224 void MirrorSelector::readPanelDescription(){
    225        
    226         m_iNumPanels = 0;
    227         QFile file( PANELFILENAME );
    228         if( file.open( IO_ReadOnly ) )
    229         {
    230                 QTextStream stream( &file );
    231                 QString line;
    232                 while( !stream.eof() )
    233                 {
    234                         line = stream.readLine();
    235                         if( line[0] == '#')
    236                                 continue;
    237                         int ii, ij, iType, iPort, iBox, iDriver, iInst;
    238                         sscanf( line.data(),"%d %d %d %d %d %d %d",
    239                                                                 &ii, &ij, &iType, &iPort,
    240                                                                 &iBox, &iDriver, &iInst );
    241                         m_Panel[ii+8][ij+8] = new AMCMirrorPanel( ii, ij, iType, iPort, iBox, iDriver );
    242                         m_Panel[ii+8][ij+8]->setInstalled(iInst != 0);
    243                         if(iInst != 0)
    244                                 m_iNumPanels++;
    245                 }
    246         }
    247         else
    248         {
    249                 int iRes = QMessageBox::critical( this,
    250                                                                                  "Can't open panel description file",
    251                                                                                  "The programm didn't find the file \'Panels.txt\'\n"
    252                                                                                  "We expect this file in the directory \'/home/amc/\'\n",
    253                                                                                  "Quit" );
    254                 exit(-1);                                                                       
    255         }
    256 
    257         file.close();
    258 }
    259 */
    260 /** Here we read the stored panel positions from the file PanelPos.txt
    261         We then go through all panels, center them and go to the stored position.
     219
     220/**
     221 * Here we read the stored panel positions from the file PanelPos.txt
     222 * We then go through all panels, center them and go to the stored position.
    262223 */
    263224void MirrorSelector::initPanelPositions()
     
    291252
    292253
    293 /** Read the stored panel positions from the file "PanelPos.txt"
    294         This file contains for each panel a line with the following contents:
    295         i       j       X       Y
    296        
    297         i: is the first panel index (counting from left to right)
    298         j: is the second panel index (counting from bottom to top)
    299         X: position of the X motor relative to the center position
    300         Y: position of the Y motor relative to the center position
    301  */
    302 /*
    303 void MirrorSelector::readPanelPositions()
    304 {
    305         QFile file( POSFILENAME );
    306         if( file.open( IO_ReadOnly ) )
    307         {
    308                 QTextStream stream( &file );
    309                 QString line;
    310                 while( !stream.eof() )
    311                 {
    312                         line = stream.readLine();
    313                        
    314                         // Skip comment lines
    315                         if( line[0] == '#')
    316                                 continue;
    317                                
    318                         int ii, ij, iX, iY;
    319                         sscanf( line.data(),"%d %d %d %d",
    320                                                                 &ii, &ij, &iX, &iY );
    321                         m_Panel[ii+8][ij+8]->setX(iX);
    322                         m_Panel[ii+8][ij+8]->setY(iY);
    323                 }
    324         }
    325         else
    326         {
    327                 int iRes = QMessageBox::critical( this,
    328                                                                                  "Can't open panel position description file",
    329                                                                                  "The programm didn't find the file \'PanelPos.txt\'\n"
    330                                                                                  "We expect this file in the directory \'/home/amc/\'\n",
    331                                                                                  "Quit" );
    332                 exit(-1);                                                                       
    333         }
    334         file.close();
    335        
    336         return;
    337 }
    338 */
    339 
    340254/** Save the positions to the file. */
    341255void MirrorSelector::savePositionsSlot()
     
    345259}
    346260
    347 /** Check to see if the right mouse button was pressed and
    348         show the context menu in this case.
    349   */
     261/**
     262 * Check to see if the right mouse button was pressed and
     263 * show the context menu in this case.
     264 */
    350265void MirrorSelector::mousePressEvent( QMouseEvent* p_pEvent )
    351266{
     
    353268                m_contextMenu->exec( QCursor::pos() );
    354269}
     270
     271/**
     272 * Change the icon to show that the laser is on or off.
     273 */
     274void MirrorSelector::toggelLaser( AMCMirrorPanel* p_pPanel, bool p_zOn )
     275{
     276        AMCPushButton* pButton = m_mirrorButton[p_pPanel->j()+8][p_pPanel->i()+8];
     277
     278        int type = p_pPanel->type();
     279        if( p_zOn )
     280                type += 6;             
     281        pButton->setPixmap( *m_pixType[type] );
     282}
  • trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/mirrorselector.h

    r3401 r4492  
    3434        ~MirrorSelector();
    3535       
    36         /** No descriptions */
    37 //      void saveMirrorPanels();
    3836        /** Check to see if the right mouse button was pressed and show the context menu in this case. */
    3937        void mousePressEvent( QMouseEvent* p_pEvent );
     
    6159        /** Context menu, shown when the user hits the right mouse button.  */
    6260        QPopupMenu* m_contextMenu;
     61        /** Array conmtaining the pixmaps for the icons of the buttons.  */
     62        QPixmap* m_pixType[13];
     63        /** Array conmtaining the bitmaps for the icon masks of the buttons.  */
     64        QBitmap* m_bitMask[6];
     65        /** Pointer to the currently selected button.  */
     66        QButton* m_pSelectedButton;
    6367       
    6468signals: // Signals
     
    104108     */
    105109//  void readPanelPositions();
     110public slots: // Public slots
     111  /** Change the icon to show that the laser is on or off.
     112 */
     113  void toggelLaser(  AMCMirrorPanel* p_pPanel, bool p_zOn );
    106114};
    107115
Note: See TracChangeset for help on using the changeset viewer.