Changeset 4494 for trunk/MagicSoft/AMC
- Timestamp:
- 08/04/04 16:54:41 (20 years ago)
- Location:
- trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/videodisplay.cpp
r4173 r4494 49 49 extern AMCFrameGrabber* g_pFG; 50 50 extern MagicMirror* g_theMirror; 51 extern int g_iRefX, g_iRefY;51 extern double g_dRefX, g_dRefY; 52 52 53 53 VideoDisplay::VideoDisplay(QWidget *parent, const char *name, bool modal ) … … 70 70 qDebug("Adding Videoframe as widget"); 71 71 ((QGridLayout*) this->layout())->addWidget( m_videoFrame, 0, 0 ); 72 connect( m_videoFrame, SIGNAL( gref( int, int ) ), this ,SLOT( setGRefInfoSlot( int, int) ) );73 connect( m_videoFrame, SIGNAL( spot( int, int ) ), this ,SLOT( setSpotInfoSlot( int, int) ) );72 connect( m_videoFrame, SIGNAL( gref(double, double ) ), this ,SLOT( setGRefInfoSlot( double, double ) ) ); 73 connect( m_videoFrame, SIGNAL( spot(double, double ) ), this ,SLOT( setSpotInfoSlot( double, double ) ) ); 74 74 connect( m_videoFrame, SIGNAL( framesGrabbed(int) ), (QObject*) GrabbedLCD ,SLOT( display( int ) ) ); 75 75 connect( m_videoFrame, SIGNAL( framesProcessed(int) ), (QObject*) ProcessedLCD ,SLOT( display( int ) ) ); … … 87 87 // ourselves. 88 88 qDebug("Creating and starting timer"); 89 89 90 m_pTimer = new QTimer( this ); 90 91 connect( m_pTimer, SIGNAL( timeout() ), m_videoFrame, SLOT( timerDone() ) ); … … 97 98 disconnect( Brightness, SIGNAL( valueChanged(int) ), g_pFG ,SLOT( setBrightness( int ) ) ); 98 99 disconnect( Contrast, SIGNAL( valueChanged(int) ), g_pFG ,SLOT( setContrast( int ) ) ); 100 disconnect( thresholdSlider, SIGNAL( valueChanged(int) ), m_videoFrame ,SLOT( threshold(int) ) ); 101 disconnect( scaleBox, SIGNAL( toggled(bool) ), m_videoFrame ,SLOT( scaleImage(bool) ) ); 102 disconnect( scaleValSlider, SIGNAL( valueChanged(int) ), m_videoFrame ,SLOT( scaleValue(int) ) ); 103 disconnect( darksBox, SIGNAL( toggled(bool) ), m_videoFrame ,SLOT( substractDarks(bool) ) ); 104 disconnect( Take_Dark_Button, SIGNAL( clicked() ), m_videoFrame ,SLOT( takeDark() ) ); 105 disconnect( Clear_Darks_Button, SIGNAL( clicked() ), m_videoFrame ,SLOT( clearDarks() ) ); 106 disconnect( m_videoFrame, 0, 0, 0 ); 99 107 disconnect( m_pTimer, SIGNAL( timeout() ), m_videoFrame, SLOT( timerDone() ) ); 108 109 m_pTimer->stop(); // stop 1 seconds timer 100 110 delete m_pTimer; 101 111 qDebug("Deleting VideoFrame"); … … 109 119 110 120 /** No descriptions */ 111 void VideoDisplay::setSpotInfoSlot( int p_iX, int p_iY )112 { 113 SpotX->setText( QString::number(p_ iX) );114 SpotY->setText( QString::number(p_ iY) );115 } 116 117 /** No descriptions */ 118 void VideoDisplay::setGRefInfoSlot( int p_iX, int p_iY )119 { 120 GRefX->setText( QString::number( p_ iX ) );121 GRefY->setText( QString::number( p_ iY ) );121 void VideoDisplay::setSpotInfoSlot( double p_dX, double p_dY ) 122 { 123 SpotX->setText( QString::number(p_dX) ); 124 SpotY->setText( QString::number(p_dY) ); 125 } 126 127 /** No descriptions */ 128 void VideoDisplay::setGRefInfoSlot( double p_dX, double p_dY ) 129 { 130 GRefX->setText( QString::number( p_dX ) ); 131 GRefY->setText( QString::number( p_dY ) ); 122 132 } 123 133 … … 144 154 RefY->setText( QString::number( m_pPanel->getLaserY() ) ); 145 155 m_videoFrame->setRef( m_pPanel->getLaserX(), m_pPanel->getLaserY() ); 146 GRefX->setText( QString::number( g_ iRefX ) );147 GRefY->setText( QString::number( g_ iRefY ) );156 GRefX->setText( QString::number( g_dRefX ) ); 157 GRefY->setText( QString::number( g_dRefY ) ); 148 158 149 159 enableButtons( true ); … … 170 180 void VideoDisplay::centerSlot() 171 181 { 172 // m_videoFrame->halt( true );182 // halt( true ); 173 183 enableButtons( false ); 174 184 g_theApp->processEvents(); … … 190 200 QMessageBox::Ok | QMessageBox:: Default ); 191 201 enableButtons( true ); 192 m_videoFrame->halt( false );202 halt( false ); 193 203 return; 194 204 } … … 196 206 m_pPanel->setY( 0 ); 197 207 enableButtons( true ); 198 m_videoFrame->halt( false ); 199 // g_theApp->processEvents(); 208 halt( false ); 200 209 */ 201 210 } … … 224 233 225 234 enableButtons( false ); 226 m_videoFrame->halt( true ); 227 g_theApp->processEvents(); 235 //halt( true ); 228 236 try 229 237 { … … 243 251 QMessageBox::Ok | QMessageBox:: Default ); 244 252 } 245 m_videoFrame->halt( false );246 253 enableButtons( true ); 254 //halt( false ); 247 255 return; 248 256 … … 300 308 void VideoDisplay::saveRefSlot() 301 309 { 302 int x = SpotX->text().toInt();303 int y = SpotY->text().toInt();310 double x = SpotX->text().toDouble(); 311 double y = SpotY->text().toDouble(); 304 312 305 313 if( x != -1) … … 318 326 void VideoDisplay::saveGRefSlot() 319 327 { 320 int x = SpotX->text().toInt();321 int y = SpotY->text().toInt();328 double x = SpotX->text().toDouble(); 329 double y = SpotY->text().toDouble(); 322 330 323 331 if( x != -1) 324 332 { 325 g_ iRefX = x;326 g_ iRefY = y;333 g_dRefX = x; 334 g_dRefY = y; 327 335 GRefX->setText( QString::number( x ) ); 328 336 GRefY->setText( QString::number( y ) ); … … 333 341 void VideoDisplay::adjustRefSlot() 334 342 { 335 int iRefX = m_pPanel->getLaserX();336 int iRefY = m_pPanel->getLaserY();337 qDebug("Reference: % d %d", iRefX, iRefY );338 if( ( iRefX == -1 ) && ( iRefY == -1) )343 double dRefX = m_pPanel->getLaserX(); 344 double dRefY = m_pPanel->getLaserY(); 345 qDebug("Reference: %5.1f %5.1f", dRefX, dRefY ); 346 if( ( dRefX < 0. ) && ( dRefY < 0. ) ) 339 347 return; 340 int iDx, iDy;341 iDx = m_videoFrame->m_iCenterX - CAMERA_X;342 iDy = m_videoFrame->m_iCenterY - CAMERA_Y;343 iRefX += iDx;344 iRefY += iDy;348 double dDx, dDy; 349 dDx = m_videoFrame->m_dCenterX - CAMERA_X; 350 dDy = m_videoFrame->m_dCenterY - CAMERA_Y; 351 dRefX += dDx; 352 dRefY += dDy; 345 353 int iStepX, iStepY; 346 calcSteps( iRefX, iRefY, iStepX, iStepY );354 calcSteps( dRefX, dRefY, iStepX, iStepY ); 347 355 moveMotors( iStepX, iStepY ); 348 356 } … … 351 359 void VideoDisplay::adjustGRefSlot() 352 360 { 353 if( ( g_ iRefX == -1 ) && ( g_iRefY == -1) )361 if( ( g_dRefX == -1. ) && ( g_dRefY == -1. ) ) 354 362 return; 355 363 int iStepX, iStepY; 356 calcSteps( g_ iRefX, g_iRefY, iStepX, iStepY );364 calcSteps( g_dRefX, g_dRefY, iStepX, iStepY ); 357 365 moveMotors( iStepX, iStepY ); 358 366 } 359 367 360 void VideoDisplay::calcSteps( int p_iRefX, int p_iRefY, int& p_iStepX, int& p_iStepY )368 void VideoDisplay::calcSteps( double p_dRefX, double p_dRefY, int& p_iStepX, int& p_iStepY ) 361 369 { 362 370 p_iStepX = p_iStepY = 0; 363 int iVSpotX = SpotX->text().toInt();364 int iVSpotY = SpotY->text().toInt();365 if( ( iVSpotX == -1 ) && ( iVSpotY == -1) )371 double dVSpotX = SpotX->text().toDouble(); 372 double dVSpotY = SpotY->text().toDouble(); 373 if( ( dVSpotX < 0. ) && ( dVSpotY < 0. ) ) 366 374 return; 367 qDebug("Spot at x,y: %4d %4d", iVSpotX, iVSpotY ); 368 qDebug("Ref at x,y: %4d %4d", p_iRefX, p_iRefY ); 369 370 double dX = p_iRefX - iVSpotX; 371 double dY = p_iRefY - iVSpotY; 372 double dAlpha1 = atan( m_pPanel->getSlopeX() ); 373 double dAlpha2 = atan( m_pPanel->getSlopeY() ); 374 double dSinA1 = sin( dAlpha1 ); 375 double dSinA2 = sin( dAlpha2 ); 376 double dCosA1 = cos( dAlpha1 ); 377 double dCosA2 = cos( dAlpha2 ); 378 379 double dFacX = dX - ( dY * dCosA2 / dSinA2 ); 380 dFacX /= ( dCosA1 - dSinA1 * dCosA2 / dSinA2 ); 381 double dFacY = (dY - dFacX * dSinA1) / dSinA2; 382 383 p_iStepX = (int) ( dFacX * m_pPanel->getConversionX() ); 384 p_iStepY = (int) ( dFacY * m_pPanel->getConversionY() ); 385 375 qDebug("Spot at x,y: %5.1f %5.1f", dVSpotX, dVSpotY ); 376 qDebug("Ref at x,y: %5.1f %5.1f", p_dRefX, p_dRefY ); 377 378 379 double dX = p_dRefX - dVSpotX; 380 double dY = p_dRefY - dVSpotY; 381 382 m_pPanel->calcSteps( dX, dY, p_iStepX, p_iStepY ); 386 383 qDebug("Steps till reference: %4d %4d", p_iStepX, p_iStepY ); 387 384 } … … 530 527 { 531 528 qDebug("Stoping VideoFrame"); 532 m_videoFrame->halt( true );529 halt( true ); 533 530 qDebug("Disabling buttons"); 534 531 enableButtons( false ); … … 542 539 enableButtons( true ); 543 540 qDebug("Restarting VideoFrame"); 544 m_videoFrame->halt( false );541 halt( false ); 545 542 } 546 543 … … 551 548 VideoDisplayBase::accept(); 552 549 } 550 551 /** No descriptions */ 552 void VideoDisplay::halt( bool p_zHalt ) 553 { 554 if ( p_zHalt == true ) 555 m_pTimer->stop(); 556 else 557 m_pTimer->start( 1000 ); 558 559 m_videoFrame->halt( p_zHalt ); 560 } -
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/videodisplay.h
r3401 r4494 64 64 virtual void storeSlot(); 65 65 /** No descriptions */ 66 virtual void setSpotInfoSlot( int p_iX, intp_iY );66 virtual void setSpotInfoSlot( double p_iX, double p_iY ); 67 67 /** No descriptions */ 68 virtual void setGRefInfoSlot( int p_iX, intp_iY );68 virtual void setGRefInfoSlot( double p_iX, double p_iY ); 69 69 /** Move the X motor 10 steps forward. */ 70 70 virtual void incX10Slot() { moveMotors( 10, 0 ); }; … … 93 93 /** Move motors relative by the given amount of steps. */ 94 94 virtual void moveMotors( int x, int y ); 95 /** No descriptions */ 96 void halt( bool p_zHalt ); 95 97 private: 96 98 /** No descriptions */ 97 99 void enableButtons( bool p_zEnable ) const; 98 void calcSteps( int p_iRefX, int p_iRefY, int& p_iStepX, int& p_iStepY );100 void calcSteps( double p_dRefX, double p_dRefY, int& p_iStepX, int& p_iStepY ); 99 101 100 102 public slots: // Public slots -
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/videodisplaybase.ui
r3401 r4494 12 12 <x>0</x> 13 13 <y>0</y> 14 <width>9 11</width>15 <height> 652</height>14 <width>948</width> 15 <height>719</height> 16 16 </rect> 17 17 </property> … … 142 142 <name>minimumSize</name> 143 143 <size> 144 <width> 30</width>144 <width>50</width> 145 145 <height>0</height> 146 146 </size> … … 148 148 <property stdset="1"> 149 149 <name>maxLength</name> 150 <number> 4</number>150 <number>6</number> 151 151 </property> 152 152 </widget> … … 164 164 <name>minimumSize</name> 165 165 <size> 166 <width> 30</width>166 <width>50</width> 167 167 <height>0</height> 168 168 </size> … … 170 170 <property stdset="1"> 171 171 <name>maxLength</name> 172 <number> 4</number>172 <number>6</number> 173 173 </property> 174 174 </widget> … … 235 235 <name>minimumSize</name> 236 236 <size> 237 <width> 30</width>237 <width>50</width> 238 238 <height>0</height> 239 239 </size> … … 245 245 <property stdset="1"> 246 246 <name>maxLength</name> 247 <number> 4</number>247 <number>6</number> 248 248 </property> 249 249 </widget> … … 261 261 <name>minimumSize</name> 262 262 <size> 263 <width> 30</width>263 <width>50</width> 264 264 <height>0</height> 265 265 </size> … … 267 267 <property stdset="1"> 268 268 <name>maxLength</name> 269 <number> 4</number>269 <number>6</number> 270 270 </property> 271 271 </widget> … … 321 321 <name>minimumSize</name> 322 322 <size> 323 <width> 30</width>323 <width>50</width> 324 324 <height>0</height> 325 325 </size> … … 327 327 <property stdset="1"> 328 328 <name>maxLength</name> 329 <number> 3</number>329 <number>6</number> 330 330 </property> 331 331 </widget> … … 354 354 <name>minimumSize</name> 355 355 <size> 356 <width> 30</width>356 <width>50</width> 357 357 <height>0</height> 358 358 </size> … … 360 360 <property stdset="1"> 361 361 <name>maxLength</name> 362 <number> 3</number>362 <number>6</number> 363 363 </property> 364 364 </widget>
Note:
See TracChangeset
for help on using the changeset viewer.