00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "RioMMTgif.h"
00019 #include "RioError.h"
00020
00021 #include <ctype.h>
00022 #include <string.h>
00023 #include <unistd.h>
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <sys/time.h>
00027 #include <sys/types.h>
00028 #include <sys/stat.h>
00029 #include <fcntl.h>
00030 #include <signal.h>
00031 #include <errno.h>
00032 #include <iostream>
00033 using namespace std;
00034
00035 RioMMCommand tgif_commands[] =
00036 {
00037 {
00038 "execute",
00039 1,
00040 ARG_STRING(0),
00041 tgif_execute_callback
00042 },
00043 {
00044 "create_box_object",
00045 8,
00046 ARG_INT(0) | ARG_INT(1) | ARG_INT(2) | ARG_INT(3) | ARG_INT(4) |
00047 ARG_INT(5) | ARG_INT(6) | ARG_STRING(7),
00048 tgif_create_box_object_callback
00049 },
00050 {
00051 "create_text_object",
00052 6,
00053 ARG_INT(0) | ARG_INT(1) | ARG_INT(2) | ARG_INT(3) | ARG_STRING(4) |
00054 ARG_STRING(5),
00055 tgif_create_text_object_callback
00056 },
00057 {
00058 "set_object_color",
00059 2,
00060 ARG_INT(0) | ARG_STRING(1),
00061 tgif_set_object_color_callback
00062 },
00063 {
00064 "rotate_object",
00065 2,
00066 ARG_INT(0) | ARG_INT(1),
00067 tgif_rotate_object_callback
00068 },
00069 {
00070 "move_object",
00071 3,
00072 ARG_INT(0) | ARG_INT(1) | ARG_INT(2),
00073 tgif_move_object_callback
00074 },
00075 {
00076 "resize_object",
00077 3,
00078 ARG_INT(0) | ARG_INT(1) | ARG_INT(2),
00079 tgif_resize_object_callback
00080 },
00081 {
00082 "remove_object",
00083 1,
00084 ARG_INT(0),
00085 tgif_remove_object_callback
00086 },
00087 {
00088 "remove_all_objects",
00089 0,
00090 0,
00091 tgif_remove_all_objects_callback
00092 }
00093 };
00094
00095
00096 CRioMMTgif::CRioMMTgif( char * VideoName,
00097 unsigned int blocksize,
00098 RioBlock numBuffers , struct timeval RTT_average,
00099 int width, int height )
00100 : CRioMMSlideShow( VideoName, blocksize, numBuffers , RTT_average )
00101 {
00102 #ifdef RIO_DEBUG2
00103 RioErr << "[RioMMTgif]: Entrou no construtor " << endl;
00104 #endif
00105
00106 Major = 1;
00107 Minor = 0;
00108 tgif_pipe[0] = 0;
00109 tgif_pipe[1] = 0;
00110 tgif_pid = 0;
00111 parentWindow = 0;
00112
00113 screenWidth = width;
00114 screenHeight = height;
00115
00116 CommandsList = tgif_commands;
00117 NumberOfCommands = sizeof(tgif_commands) / sizeof(RioMMCommand);
00118
00119 #ifdef RIO_DEBUG2
00120 RioErr << "[RioMMTgif]: Achou " << NumberOfCommands << " comandos" << endl;
00121 RioErr << "[RioMMTgif]: Saindo do construtor" << endl;
00122 #endif
00123 }
00124
00125
00126 CRioMMTgif::~CRioMMTgif( void )
00127 {
00128 #ifdef RIO_DEBUG2
00129 RioErr << "[RioMMTgif]: Entrou no destrutor" << endl;
00130 #endif
00131
00132 Cleanup();
00133
00134 #ifdef RIO_DEBUG2
00135 RioErr << "[RioMMTgif]: Saindo do destrutor" << endl;
00136 #endif
00137 }
00138
00139
00140 void CRioMMTgif::setParent( int window )
00141 {
00142 parentWindow = window;
00143 }
00144
00145
00146 int CRioMMTgif::init( void )
00147 {
00148 int argc;
00149 char *argv[ 100 ];
00150 char str_parentWindow[ 100 ];
00151 char resolution[ 100 ];
00152
00153
00154
00155 sprintf( resolution , "762x695-%d-%d", screenWidth-685, screenHeight-546 );
00156
00157 if( chdir( (const char *) TempDirectory ) == -1 )
00158 {
00159 RioErr << "CRioMMTgif::init erro " << errno << "(" << strerror( errno )
00160 << ") ao mudar (chdir) para o diretorio" << TempDirectory
00161 << endl;
00162 }
00163
00164
00165 sprintf( str_parentWindow, "%d", parentWindow );
00166 argc = 0;
00167 argv[ argc++ ] = strdup( "tgif" );
00168 argv[ argc++ ] = strdup( "-parent" );
00169 argv[ argc++ ] = strdup( str_parentWindow );
00170 argv[ argc++ ] = strdup( "-hyper" );
00171 argv[ argc++ ] = strdup( "-geometry" );
00172 argv[ argc++ ] = resolution;
00173 argv[ argc++ ] = strdup( "-xrm" );
00174 argv[ argc++ ] = strdup( "Tgif.AllowLaunchInHyperSpace: true" );
00175 argv[ argc++ ] = strdup( "-xrm" );
00176 argv[ argc++ ] = strdup( "Tgif.CanvasWindowOnly: true" );
00177 argv[ argc++ ] = strdup( "-xrm" );
00178 argv[ argc++ ] = strdup( "Tgif.InitialShowGrid: false" );
00179 argv[ argc++ ] = strdup( "-xrm" );
00180 argv[ argc++ ] = strdup( "Tgif.Btn2PopupMainMenu: false" );
00181 argv[ argc++ ] = strdup( "-xrm" );
00182 argv[ argc++ ] = strdup( "Tgif.EnableMouseWheel: false" );
00183
00184 argv[ argc++ ] = strdup( "-exec" );
00185 argv[ argc++ ] = strdup( "-" );
00186 argv[ argc++ ] = NULL;
00187
00188
00189 if( pipe( tgif_pipe ) < 0 )
00190 {
00191 Rioperror( "pipe" );
00192 return( 0 );
00193 }
00194 if( dup2( tgif_pipe[ 0 ], 0 ) == -1 )
00195 {
00196 Rioperror( "dup2" );
00197 return( 0 );
00198 }
00199
00200 if( (tgif_pid = fork()) != 0 )
00201 {
00202 if( tgif_pid < 0 )
00203 {
00204 Rioperror( "fork" );
00205 return( 0 );
00206 }
00207 }
00208 else
00209 {
00210 int null_file;
00211
00212 null_file = open( "/dev/null", O_WRONLY );
00213 if( null_file > 0 )
00214 dup2( null_file, 1 );
00215
00216 if( execvp( argv[ 0 ], argv ) < 0 )
00217 {
00218 Rioperror( "execvp" );
00219 exit( 1 );
00220 }
00221 }
00222
00223
00224 sleep( 1 );
00225
00226 SyncSpecific();
00227
00228
00229 RioBlock block = 1;
00230
00231
00232
00233 SyncMedia( (void *)block );
00234
00235 return CRioMMSlideShow::init();
00236 }
00237
00238
00239 void CRioMMTgif::SyncSpecific( void )
00240 {
00241 }
00242
00243
00244 int CRioMMTgif::Cleanup( void )
00245 {
00246 int status;
00247
00248 #ifdef RIO_DEBUG2
00249 RioErr << "[RioMMTgif]: Entrei na Cleanup" << endl;
00250 #endif
00251
00252 if( tgif_pid > 0 )
00253 {
00254
00255 SendCmd( "set_file_not_modified()\n" );
00256 SendCmd( "call_simple_shortcut(Quit)\n" );
00257
00258 kill( tgif_pid, SIGKILL );
00259 tgif_pid = 0;
00260
00261 status = 1;
00262 }
00263 else
00264 status = 0;
00265
00266 #ifdef RIO_DEBUG2
00267 RioErr << "[RioMMTgif]: Saindo da Cleanup" << endl;
00268 #endif
00269 return status;
00270 }
00271
00272
00273 void CRioMMTgif::Stop( void )
00274 {
00275 #ifdef RIO_DEBUG2
00276 RioErr << "[RioMMTgif]: Entrei na Stop" << endl;
00277 #endif
00278
00279 SendCmd( "set_file_not_modified()\n" );
00280
00281 CRioMMSlideShow::Stop();
00282
00283 #ifdef RIO_DEBUG2
00284 RioErr << "[RioMMTgif]: Saindo da Stop" << endl;
00285 #endif
00286 }
00287
00288 bool CRioMMTgif::ChangeContext( const char * file_name, int slide_number )
00289 {
00290 #ifdef RIO_DEBUG2
00291 RioErr << "[RioMMTgif]: Entrando na ChangeContext" << endl;
00292 #endif
00293
00294 RemoveAllObjectsCallback();
00295 if( tgif_pid <= 0 )
00296 {
00297 RioErr << "Cannot changed context without TGIF" << endl;
00298 return false;
00299 }
00300
00301 if( TString( file_name ) != CurrentFileName )
00302 {
00303 Command = "call_one_arg_shortcut(Open," + TempDirectory + "/"
00304 + TString( file_name ) + ")\n";
00305 SendCmd( (const char *)Command );
00306 }
00307
00308 Command.Format( "call_one_arg_shortcut(GotoPage,%d)\n", slide_number );
00309 SendCmd( (const char *)Command );
00310
00311 CRioMMSlideShow::ChangeContext( file_name, slide_number );
00312
00313 #ifdef RIO_DEBUG2
00314 RioErr << "[RioMMTgif]: Saindo da ChangeContext " << endl;
00315 #endif
00316
00317 return true;
00318 }
00319
00320
00321
00322
00323
00324
00325
00326 void CRioMMTgif::SendCmd( const char *command )
00327 {
00328 int escritos;
00329 escritos = write( tgif_pipe[ 1 ], command, strlen( command ) );
00330
00331 if( escritos != (int) strlen( command ) )
00332 {
00333 RioErr << "CRioMMTgif::SendCmd erro ao escrever o valor de command: "
00334 << "escritos "<< escritos << " bytes de um total de"
00335 << strlen( command ) << " bytes." << endl;
00336 }
00337 else if( escritos == -1 )
00338 {
00339 RioErr << "CRioMMTgif::SendCmd erro " << errno << "("
00340 << strerror( errno ) << ") ao escrever o valor de command."
00341 << endl;
00342 }
00343
00344 usleep( 1 );
00345 }
00346
00347
00348
00349
00350
00351
00352
00353 int CRioMMTgif::ProcessSignal( int sig, void *data )
00354 {
00355 int status;
00356
00357 status = 0;
00358 switch( sig )
00359 {
00360 case SIGCHLD:
00361 if( (int) (long long int) data == tgif_pid )
00362 status = 2;
00363 break;
00364 }
00365
00366 if( status != 2 )
00367 CRioMMObject::ProcessSignal( sig, data );
00368
00369 return( status );
00370 }
00371
00372
00373
00374
00375
00376
00377 void CRioMMTgif::ExecuteCallback( const char *command )
00378 {
00379 #ifdef RIO_DEBUG2
00380 RioErr << "[RioMMTgif]: Entrei na ExecuteCallback" << endl;
00381 #endif
00382
00383 if( tgif_pid <= 0 )
00384 {
00385 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00386 return;
00387 }
00388
00389 if( command == NULL )
00390 return;
00391
00392 SendCmd( command );
00393 SendCmd( "\n" );
00394
00395 #ifdef RIO_DEBUG2
00396 RioErr << "[RioMMTgif]: Saindo da ExecuteCallback " << endl;
00397 #endif
00398 }
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408 void CRioMMTgif::CreateBoxObjectCallback( int oid, int type, int x1, int y1,
00409 int x2, int y2, int lwidth, const char * color )
00410 {
00411 struct timeval t;
00412 int side_size, head_size;
00413
00414 #ifdef RIO_DEBUG2
00415 RioErr << "[RioMMTgif]: Entrei na CreateBoxObjectCallback" << endl;
00416 #endif
00417
00418 if( tgif_pid <= 0 )
00419 {
00420 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00421 return;
00422 }
00423
00424 if( oid >= MAX_OBJECTS || oid < 0 )
00425 {
00426 RioErr << "Invalid object ID " << oid
00427 << ". Valid numbers are in the range of 0 to "
00428 << MAX_OBJECTS-1 << endl;
00429 return;
00430 }
00431
00432 if( (const char *)object_names[ oid ] != NULL )
00433 {
00434 RioErr << "Cannot create a box object with ID " << oid
00435 << " because this number is already in use." << endl;
00436 return;
00437 }
00438
00439 if( x1 >= x2 || y1 >= y2 )
00440 {
00441 RioErr << "Invalid coordinates for a box." << endl;
00442 return;
00443 }
00444
00445 gettimeofday( &t, NULL );
00446 object_names[ oid ].Format( "hid%ld%ld", t.tv_sec, t.tv_usec );
00447
00448
00449 SendCmd( "set_redraw(FALSE)\n" );
00450 SendCmd( "set_allow_interrupt(FALSE)\n" );
00451 SendCmd( "unselect_all_obj()\n" );
00452 SendCmd( "set_selected_obj_fill(0)\n" );
00453
00454
00455 switch( type )
00456 {
00457 case TGIF_BOX_OBJECT_RCBOX:
00458 Command.Format( "create_rcbox_obj(%d,%d,%d,%d)\n",
00459 x1, y1, x2, y2 );
00460 SendCmd( (const char *)Command );
00461 break;
00462 case TGIF_BOX_OBJECT_OVAL:
00463 Command.Format( "create_corner_oval_obj(%d,%d,%d,%d)\n",
00464 x1, y1, x2, y2 );
00465 SendCmd( (const char *)Command );
00466 break;
00467 case TGIF_BOX_OBJECT_ARROW:
00468 side_size = abs(y2-y1)/4;
00469 head_size = (2*abs(x2-x1))/5;
00470 SendCmd( "start_create_group_obj()\n" );
00471 Command.Format( "create_first_vertex(%d,%d)\n", x1, y1+side_size );
00472 SendCmd( (const char *)Command );
00473 Command.Format( "create_next_vertex(%d,%d)\n", x2-head_size,
00474 y1+side_size );
00475 SendCmd( (const char *)Command );
00476 Command.Format( "create_next_vertex(%d,%d)\n", x2-head_size, y1 );
00477 SendCmd( (const char *)Command );
00478 Command.Format( "create_next_vertex(%d,%d)\n", x2, (y1+y2)/2 );
00479 SendCmd( (const char *)Command );
00480 Command.Format( "create_next_vertex(%d,%d)\n", x2-head_size, y2 );
00481 SendCmd( (const char *)Command );
00482 Command.Format( "create_next_vertex(%d,%d)\n", x2-head_size,
00483 y2-side_size );
00484 SendCmd( (const char *)Command );
00485 Command.Format( "create_next_vertex(%d,%d)\n", x1, y2-side_size );
00486 SendCmd( (const char *)Command );
00487 SendCmd( "create_polygon_obj()\n" );
00488 SendCmd( "create_group_obj()\n" );
00489 break;
00490 case TGIF_BOX_OBJECT_RECTANGLE:
00491 default:
00492 Command.Format( "create_box_obj(%d,%d,%d,%d)\n",
00493 x1, y1, x2, y2 );
00494 SendCmd( (const char *)Command );
00495 break;
00496 }
00497
00498
00499 SendCmd( "select_top_obj()\n" );
00500
00501
00502 Command.Format( "add_attr_to_selected_obj(name,%s,NULL,NULL)\n",
00503 (const char *)object_names[ oid ] );
00504 SendCmd( (const char *)Command );
00505
00506
00507 Command.Format( "hide_attr(%s.name)\n", (const char*)object_names[oid] );
00508 SendCmd( (const char *)Command );
00509
00510
00511 Command.Format( "set_selected_obj_line_width(%d,-1,-1)\n", lwidth );
00512 SendCmd( (const char *)Command );
00513
00514
00515 if( color && strlen(color) > 0 )
00516 {
00517 Command.Format( "set_selected_obj_color(%s)\n", color );
00518 SendCmd( (const char *)Command );
00519 }
00520 else
00521 SendCmd( "set_selected_obj_color(black)\n" );
00522
00523 SendCmd( "unselect_all_obj()\n" );
00524 SendCmd( "set_allow_interrupt(TRUE)\n" );
00525 SendCmd( "set_redraw(TRUE)\n" );
00526
00527 #ifdef RIO_DEBUG2
00528 RioErr << "[RioMMTgif]: Saindo da CreateBoxObjectCallback" << endl;
00529 #endif
00530 }
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540 void CRioMMTgif::CreateTextObjectCallback( int oid, int x, int y, int size,
00541 const char * color, const char * text )
00542 {
00543 struct timeval t;
00544
00545 #ifdef RIO_DEBUG2
00546 RioErr << "[RioMMTgif]: Entrei na CreateTextObjectCallback" << endl;
00547 #endif
00548
00549 if( tgif_pid <= 0 )
00550 {
00551 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00552 return;
00553 }
00554
00555 if( oid >= MAX_OBJECTS || oid < 0 )
00556 {
00557 RioErr << "Invalid object ID " << oid
00558 << ". Valid numbers are in the range of 0 to "
00559 << MAX_OBJECTS-1 << endl;
00560 return;
00561 }
00562
00563 if( (const char *)object_names[ oid ] != NULL )
00564 {
00565 RioErr << "Cannot create a text object object with ID " << oid
00566 << " because this number is already in use." << endl;
00567 return;
00568 }
00569
00570 if( text == NULL || strlen(text) < 1 )
00571 {
00572 RioErr << "Cannot create an empty text object" << endl;
00573 return;
00574 }
00575
00576 gettimeofday( &t, NULL );
00577 object_names[ oid ].Format( "hid%ld%ld", t.tv_sec, t.tv_usec );
00578
00579
00580 SendCmd( "set_redraw(FALSE)\n" );
00581 SendCmd( "set_allow_interrupt(FALSE)\n" );
00582
00583
00584 SendCmd( "start_create_group_obj()\n" );
00585 SendCmd( "create_box_obj(-2,-2,-1,-1)\n" );
00586 Command.Format( "create_text_obj(%d,%d,%s)\n", x, y, text );
00587 SendCmd( (const char *)Command );
00588 SendCmd( "create_group_obj()\n" );
00589
00590
00591 SendCmd( "select_top_obj()\n" );
00592
00593
00594 Command.Format( "add_attr_to_selected_obj(name,%s,NULL,NULL)\n",
00595 (const char *)object_names[ oid ] );
00596 SendCmd( (const char *)Command );
00597
00598
00599 Command.Format( "hide_attr(%s.name)\n", (const char*)object_names[oid] );
00600 SendCmd( (const char *)Command );
00601
00602
00603 Command.Format( "set_selected_text_size(%d)\n", size );
00604 SendCmd( (const char *)Command );
00605 SendCmd( "set_selected_text_just(left)\n" );
00606
00607
00608 if( color && strlen(color) > 0 )
00609 {
00610 Command.Format( "set_selected_obj_color(%s)\n", color );
00611 SendCmd( (const char *)Command );
00612 }
00613 else
00614 SendCmd( "set_selected_obj_color(black)\n" );
00615
00616 SendCmd( "unselect_all_obj()\n" );
00617 SendCmd( "set_allow_interrupt(TRUE)\n" );
00618 SendCmd( "set_redraw(TRUE)\n" );
00619
00620 #ifdef RIO_DEBUG2
00621 RioErr << "[RioMMTgif]: Saindo da CreateTextObjectCallback" << endl;
00622 #endif
00623 }
00624
00625
00626
00627
00628
00629
00630 void CRioMMTgif::SetObjectColorCallback( int oid, const char * color )
00631 {
00632 #ifdef RIO_DEBUG2
00633 RioErr << "[RioMMTgif]: Entrei na MoveObjectCallback" << endl;
00634 #endif
00635
00636 if( tgif_pid <= 0 )
00637 {
00638 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00639 return;
00640 }
00641
00642 if( oid >= MAX_OBJECTS || oid < 0 )
00643 {
00644 RioErr << "Invalid object ID " << oid
00645 << ". Valid numbers are in the range of 0 to "
00646 << MAX_OBJECTS-1 << endl;
00647 return;
00648 }
00649
00650 if( (const char *)object_names[ oid ] == NULL )
00651 {
00652 RioErr << "Cannot set the color for object with ID " << oid
00653 << " because it was not created yet." << endl;
00654 return;
00655 }
00656
00657 if( color == NULL || strlen(color) < 1 )
00658 {
00659 RioErr << "Invalid color" << endl;
00660 return;
00661 }
00662
00663
00664 SendCmd( "set_redraw(FALSE)\n" );
00665 SendCmd( "set_allow_interrupt(FALSE)\n" );
00666 Command = "select_obj_by_name(" + object_names[ oid ] + ")\n";
00667 SendCmd( (const char *)Command );
00668 Command.Format( "set_selected_obj_color(%s)\n", color );
00669 SendCmd( (const char *)Command );
00670 SendCmd( "unselect_all_obj()\n" );
00671 SendCmd( "set_allow_interrupt(TRUE)\n" );
00672 SendCmd( "set_redraw(TRUE)\n" );
00673
00674 #ifdef RIO_DEBUG2
00675 RioErr << "[RioMMTgif]: Saindo da MoveObjectCallback " << endl;
00676 #endif
00677 }
00678
00679
00680
00681
00682
00683
00684 void CRioMMTgif::RotateObjectCallback( int oid, int angle )
00685 {
00686 #ifdef RIO_DEBUG2
00687 RioErr << "[RioMMTgif]: Entrei na MoveObjectCallback" << endl;
00688 #endif
00689
00690 if( tgif_pid <= 0 )
00691 {
00692 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00693 return;
00694 }
00695
00696 if( oid >= MAX_OBJECTS || oid < 0 )
00697 {
00698 RioErr << "Invalid object ID " << oid
00699 << ". Valid numbers are in the range of 0 to "
00700 << MAX_OBJECTS-1 << endl;
00701 return;
00702 }
00703
00704 if( (const char *)object_names[ oid ] == NULL )
00705 {
00706 RioErr << "Cannot rotate object with ID " << oid
00707 << " because it was not created yet." << endl;
00708 return;
00709 }
00710
00711
00712 SendCmd( "set_redraw(FALSE)\n" );
00713 SendCmd( "set_allow_interrupt(FALSE)\n" );
00714 Command = "select_obj_by_name(" + object_names[ oid ] + ")\n";
00715 SendCmd( (const char *)Command );
00716 Command.Format( "rotate_selected_obj(%d)\n", angle );
00717 SendCmd( (const char *)Command );
00718 SendCmd( "unselect_all_obj()\n" );
00719 SendCmd( "set_allow_interrupt(TRUE)\n" );
00720 SendCmd( "set_redraw(TRUE)\n" );
00721
00722 #ifdef RIO_DEBUG2
00723 RioErr << "[RioMMTgif]: Saindo da MoveObjectCallback " << endl;
00724 #endif
00725 }
00726
00727
00728
00729
00730
00731
00732 void CRioMMTgif::MoveObjectCallback( int oid, int x, int y )
00733 {
00734 #ifdef RIO_DEBUG2
00735 RioErr << "[RioMMTgif]: Entrei na MoveObjectCallback" << endl;
00736 #endif
00737
00738 if( tgif_pid <= 0 )
00739 {
00740 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00741 return;
00742 }
00743
00744 if( oid >= MAX_OBJECTS || oid < 0 )
00745 {
00746 RioErr << "Invalid object ID " << oid
00747 << ". Valid numbers are in the range of 0 to "
00748 << MAX_OBJECTS-1 << endl;
00749 return;
00750 }
00751
00752 if( (const char *)object_names[ oid ] == NULL )
00753 {
00754 RioErr << "Cannot move object with ID " << oid
00755 << " because it was not created yet." << endl;
00756 return;
00757 }
00758
00759
00760 SendCmd( "set_redraw(FALSE)\n" );
00761 SendCmd( "set_allow_interrupt(FALSE)\n" );
00762 Command = "select_obj_by_name(" + object_names[ oid ] + ")\n";
00763 SendCmd( (const char *)Command );
00764 Command.Format( "move_selected_obj_absolute(%d,%d)\n", x, y );
00765 SendCmd( (const char *)Command );
00766 SendCmd( "unselect_all_obj()\n" );
00767 SendCmd( "set_allow_interrupt(TRUE)\n" );
00768 SendCmd( "set_redraw(TRUE)\n" );
00769
00770 #ifdef RIO_DEBUG2
00771 RioErr << "[RioMMTgif]: Saindo da MoveObjectCallback " << endl;
00772 #endif
00773 }
00774
00775
00776
00777
00778
00779
00780 void CRioMMTgif::ResizeObjectCallback( int oid, int w, int h )
00781 {
00782 #ifdef RIO_DEBUG2
00783 RioErr << "[RioMMTgif]: Entrei na ResizeObjectCallback" << endl;
00784 #endif
00785
00786 if( tgif_pid <= 0 )
00787 {
00788 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00789 return;
00790 }
00791
00792 if( oid >= MAX_OBJECTS || oid < 0 )
00793 {
00794 RioErr << "Invalid object ID " << oid
00795 << ". Valid numbers are in the range of 0 to "
00796 << MAX_OBJECTS-1 << endl;
00797 return;
00798 }
00799
00800 if( (const char *)object_names[ oid ] == NULL )
00801 {
00802 RioErr << "Cannot resize object with ID " << oid
00803 << " because it was not created yet." << endl;
00804 return;
00805 }
00806
00807
00808 SendCmd( "set_redraw(FALSE)\n" );
00809 SendCmd( "set_allow_interrupt(FALSE)\n" );
00810 Command.Format( "size_named_obj_absolute(%s,%d,%d)\n",
00811 (const char *)object_names[ oid ], w, h );
00812 SendCmd( (const char *)Command );
00813 SendCmd( "unselect_all_obj()\n" );
00814 SendCmd( "set_allow_interrupt(TRUE)\n" );
00815 SendCmd( "set_redraw(TRUE)\n" );
00816
00817 #ifdef RIO_DEBUG2
00818 RioErr << "[RioMMTgif]: Saindo da ResizeObjectCallback " << endl;
00819 #endif
00820 }
00821
00822
00823
00824
00825
00826
00827 void CRioMMTgif::RemoveObjectCallback( int oid )
00828 {
00829 #ifdef RIO_DEBUG2
00830 RioErr << "[RioMMTgif]: Entrei na RemoveObjectCallback" << endl;
00831 #endif
00832
00833 if( tgif_pid <= 0 )
00834 {
00835 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00836 return;
00837 }
00838
00839 if( oid >= MAX_OBJECTS || oid < 0 )
00840 {
00841 RioErr << "Invalid object ID " << oid
00842 << ". Valid numbers are in the range of 0 to "
00843 << MAX_OBJECTS-1 << endl;
00844 return;
00845 }
00846
00847 if( (const char *)object_names[ oid ] == NULL )
00848 {
00849 RioErr << "Cannot remove object with ID " << oid
00850 << " because it was not created yet." << endl;
00851 return;
00852 }
00853
00854
00855 SendCmd( "set_redraw(FALSE)\n" );
00856 SendCmd( "set_allow_interrupt(FALSE)\n" );
00857 Command = "select_obj_by_name(" + object_names[ oid ] + ")\n";
00858 SendCmd( (const char *)Command );
00859 SendCmd( "delete_selected_obj()\n" );
00860 SendCmd( "unselect_all_obj()\n" );
00861 SendCmd( "set_allow_interrupt(TRUE)\n" );
00862 SendCmd( "set_redraw(TRUE)\n" );
00863
00864 object_names[ oid ] = NULL;
00865
00866 #ifdef RIO_DEBUG2
00867 RioErr << "[RioMMTgif]: Saindo da RemoveObjectCallback" << endl;
00868 #endif
00869 }
00870
00871
00872
00873
00874
00875
00876 void CRioMMTgif::RemoveAllObjectsCallback( void )
00877 {
00878 int i;
00879
00880 #ifdef RIO_DEBUG2
00881 RioErr << "[RioMMTgif]: Entrei na RemoveAllObjectsCallback" << endl;
00882 #endif
00883 if( tgif_pid <= 0 )
00884 {
00885 RioErr << "Cannot send commands to tgif: broken pipe" << endl;
00886 return;
00887 }
00888
00889 for( i = 0; i < MAX_OBJECTS; i++ )
00890 {
00891 if( (const char *)object_names[ i ] != NULL )
00892 RemoveObjectCallback( i );
00893 }
00894
00895 #ifdef RIO_DEBUG2
00896 RioErr << "[RioMMTgif]: Saindo da RemoveAllObjectsCallback " << endl;
00897 #endif
00898 }
00899
00900 pid_t CRioMMTgif::GetTgifpid( void )
00901 {
00902 return tgif_pid;
00903 }
00904
00905
00906
00907
00908
00909
00910
00911 void tgif_execute_callback( void * param, TQueue & args )
00912 {
00913 TString * arg1;
00914
00915 arg1 = (TString *)args.Remove( );
00916
00917 ((CRioMMTgif *)param)->ExecuteCallback( (const char *)*arg1 );
00918
00919 delete arg1;
00920 }
00921
00922 void tgif_create_box_object_callback( void * param, TQueue & args )
00923 {
00924 int arg[ 7 ];
00925 TString * arg8;
00926
00927 arg[ 0 ] = (int) (long long int) args.Remove( );
00928 arg[ 1 ] = (int) (long long int) args.Remove( );
00929 arg[ 2 ] = (int) (long long int) args.Remove( );
00930 arg[ 3 ] = (int) (long long int) args.Remove( );
00931 arg[ 4 ] = (int) (long long int) args.Remove( );
00932 arg[ 5 ] = (int) (long long int) args.Remove( );
00933 arg[ 6 ] = (int) (long long int) args.Remove( );
00934 arg8 = (TString *)args.Remove( );
00935
00936 ((CRioMMTgif *)param)->CreateBoxObjectCallback( arg[ 0 ], arg[ 1 ],
00937 arg[ 2 ], arg[ 3 ], arg[ 4 ], arg[ 5 ],
00938 arg[ 6 ], (const char *)*arg8 );
00939
00940 delete arg8;
00941 }
00942
00943 void tgif_create_text_object_callback( void * param, TQueue & args )
00944 {
00945 int arg[ 4 ];
00946 TString * arg5, * arg6;
00947
00948 arg[ 0 ] = (int) (long long int) args.Remove( );
00949 arg[ 1 ] = (int) (long long int) args.Remove( );
00950 arg[ 2 ] = (int) (long long int) args.Remove( );
00951 arg[ 3 ] = (int) (long long int) args.Remove( );
00952 arg5 = (TString *)args.Remove( );
00953 arg6 = (TString *)args.Remove( );
00954
00955 ((CRioMMTgif *)param)->CreateTextObjectCallback( arg[ 0 ], arg[ 1 ],
00956 arg[ 2 ], arg[ 3 ], (const char *)*arg5, (const char *)*arg6 );
00957
00958 delete arg5;
00959 delete arg6;
00960 }
00961
00962 void tgif_set_object_color_callback( void * param, TQueue & args )
00963 {
00964 int arg1;
00965 TString * arg2;
00966
00967 arg1 = (int) (long long int) args.Remove( );
00968 arg2 = (TString *)args.Remove( );
00969
00970 ((CRioMMTgif *)param)->SetObjectColorCallback( arg1,
00971 (const char *)*arg2 );
00972
00973 delete arg2;
00974 }
00975
00976 void tgif_rotate_object_callback( void * param, TQueue & args )
00977 {
00978 int arg[ 2 ];
00979
00980 arg[ 0 ] = (int) (long long int) args.Remove( );
00981 arg[ 1 ] = (int) (long long int) args.Remove( );
00982
00983 ((CRioMMTgif *)param)->RotateObjectCallback( arg[ 0 ], arg[ 1 ] );
00984 }
00985
00986 void tgif_move_object_callback( void * param, TQueue & args )
00987 {
00988 int arg[ 3 ];
00989
00990 arg[ 0 ] = (int) (long long int) args.Remove( );
00991 arg[ 1 ] = (int) (long long int) args.Remove( );
00992 arg[ 2 ] = (int) (long long int) args.Remove( );
00993
00994 ((CRioMMTgif *)param)->MoveObjectCallback( arg[ 0 ], arg[ 1 ],
00995 arg[ 2 ] );
00996 }
00997
00998 void tgif_resize_object_callback( void * param, TQueue & args )
00999 {
01000 int arg[ 3 ];
01001
01002 arg[ 0 ] = (int) (long long int) args.Remove( );
01003 arg[ 1 ] = (int) (long long int) args.Remove( );
01004 arg[ 2 ] = (int) (long long int) args.Remove( );
01005
01006 ((CRioMMTgif *)param)->ResizeObjectCallback( arg[ 0 ], arg[ 1 ],
01007 arg[ 2 ] );
01008 }
01009
01010 void tgif_remove_object_callback( void * param, TQueue & args )
01011 {
01012 int arg1;
01013
01014 arg1 = (int) (long long int) args.Remove( );
01015
01016 ((CRioMMTgif *)param)->RemoveObjectCallback( arg1 );
01017 }
01018
01019 void tgif_remove_all_objects_callback( void * param, TQueue & args )
01020 {
01021 ((CRioMMTgif *)param)->RemoveAllObjectsCallback( );
01022 }