void MdispGtkView::FillDisplay( bool on ) { if(m_MilDisplay) { // Fill display is incompatible with pan. pan( 0, 0 ); if(on) { // disable temporary using user's XDisplay // filldisplay can generate excessive expose ( paint) event // this can freeze main menu window MdispControl(m_MilDisplay,M_WINDOW_ANNOTATIONS,M_NULL); } else { MdispControl(m_MilDisplay,M_WINDOW_ANNOTATIONS,M_PTR_TO_DOUBLE(GDK_WINDOW_XDISPLAY(m_window->window))); } //Using MIL, enable/disable Fill Display Mode [CALL TO MIL] MdispControl(m_MilDisplay, M_FILL_DISPLAY, on ? M_ENABLE : M_DISABLE); m_isFillDisplayEnabled = on; UpdateContentSize(); } }
void MdispGtkView::ChangeAsynchronousMode(bool Enabled, MIL_INT FrameRate) { if(Enabled && (FrameRate != m_currentAsynchronousFrameRate)) { if(m_MilDisplay) { // Apply asynchronous frame rate to display [CALL TO MIL] MdispControl(m_MilDisplay, M_UPDATE_RATE_MAX, FrameRate); // Check if control worked correctly before considering it successful [CALL TO MIL] if(MdispInquire(m_MilDisplay, M_UPDATE_RATE_MAX, M_NULL) == FrameRate) { m_currentAsynchronousFrameRate = FrameRate; } } } if((Enabled && !m_isInAsynchronousMode) || (!Enabled && m_isInAsynchronousMode)) { if(m_MilDisplay) { // Apply asynchronous update to display [CALL TO MIL] MdispControl(m_MilDisplay, M_ASYNC_UPDATE, (Enabled ? M_ENABLE : M_DISABLE)); // Check if control worked correctly before considering it successful [CALL TO MIL] if(MdispInquire(m_MilDisplay, M_ASYNC_UPDATE, M_NULL) == (Enabled ? M_ENABLE : M_DISABLE)) { m_isInAsynchronousMode = Enabled; } } } }
void MdispGtkView::ROIDefine(bool on) { ///////////////////////////////////////////////////////////////////////// // MIL: Write code that will be executed when 'ROI Define ' // menu is clicked. State toggles. ///////////////////////////////////////////////////////////////////////// if(m_MilDisplay && m_isROISupported) { MdispControl(m_MilDisplay, M_ROI_DEFINE, on?(M_START+M_RESET):M_STOP); m_isInROIDefineMode = on; // Make sure Interpolation Mode combo box shows current interpolation mode m_currentInterpolationMode = MdispInquire(m_MilDisplay, M_INTERPOLATION_MODE, M_NULL); if(MdispInquire(m_MilDisplay, M_DISPLAY_TYPE, M_NULL) & M_EXCLUSIVE) { //when ROI mode is active, allow the mouse to be used in the exclusive display monitor if(m_isInROIDefineMode) { MdispControl(m_MilDisplay, M_RESTRICT_CURSOR, M_DISABLE); } else { MdispControl(m_MilDisplay, M_RESTRICT_CURSOR, M_ENABLE); } } } }
void MdispGtkView::Overlay(bool on) { // Enable overlay if (on && !m_isOverlayEnabled) { MdispControl(m_MilDisplay, M_OVERLAY, M_ENABLE); //If overlay buffer as not been initialized yet, do it now. if(!m_isOverlayInitialized) InitializeOverlay(); m_isOverlayEnabled = true; } // Disable overlay else if (!on && m_isOverlayEnabled) { // Disable the overlay display. [CALL TO MIL] MdispControl(m_MilDisplay, M_OVERLAY, M_DISABLE); m_isOverlayInitialized = false; m_isOverlayEnabled = false; } ///////////////////////////////////////////////////////////////////////// // MIL: Write code that will be executed when 'add overlay' is selected ///////////////////////////////////////////////////////////////////////// }
void MdispGtkView::GraphicsAnnotations( bool on ) { if(m_MilDisplay) { m_isGraphicsAnnotationsEnabled = on; if(m_isGraphicsAnnotationsEnabled) { if(!m_MilGraphContext && !m_MilGraphList) { MIL_INT BufSizeX = 0, BufSizeY = 0; MIL_INT LogoCellSize = 12; MIL_INT LogoSize = 6 * LogoCellSize; MIL_INT Offset = 10; MgraAlloc(((MdispGtkApp*)dispGtkApp())->m_MilSystem, &m_MilGraphContext); MgraAllocList(((MdispGtkApp*)dispGtkApp())->m_MilSystem, M_DEFAULT, &m_MilGraphList); MdispControl(m_MilDisplay, M_DISPLAY_GRAPHIC_LIST, m_MilGraphList); MdispControl(m_MilDisplay, M_UPDATE_GRAPHIC_LIST, M_DISABLE); MbufInquire(m_MilImage, M_SIZE_X, &BufSizeX); MbufInquire(m_MilImage, M_SIZE_Y, &BufSizeY); MgraClear(m_MilGraphContext, m_MilGraphList); GraphicLogo(Offset , Offset , LogoCellSize); GraphicLogo(BufSizeX - (LogoSize/2), Offset , LogoCellSize); GraphicLogo(Offset , BufSizeY + Offset, LogoCellSize); MgraColor(m_MilGraphContext, M_COLOR_LIGHT_BLUE); MgraLine(m_MilGraphContext, m_MilGraphList, Offset + (LogoSize/2), Offset + LogoSize, Offset + LogoSize/2, BufSizeY + Offset); MgraLine(m_MilGraphContext, m_MilGraphList, Offset + LogoSize, Offset + (LogoSize/2), BufSizeX - (LogoSize/2), Offset + (LogoSize/2)); MgraColor(m_MilGraphContext, M_COLOR_GRAY); MgraText(m_MilGraphContext, m_MilGraphList, Offset, (2*Offset)+LogoSize, MT("Mil Graphic")); MgraText(m_MilGraphContext, m_MilGraphList, Offset, (4*Offset)+LogoSize, MT("Annotations")); MdispControl(m_MilDisplay, M_UPDATE_GRAPHIC_LIST, M_ENABLE); } } else { MdispControl(m_MilDisplay, M_DISPLAY_GRAPHIC_LIST, M_NULL); if(m_MilGraphList) { MgraFree(m_MilGraphList); m_MilGraphList = M_NULL; } if(m_MilGraphContext) { MgraFree(m_MilGraphContext); m_MilGraphContext = M_NULL; } } } }
void RoiPrefsDlg::on_RoiHandlesButton_clicked() { QColor c = QColorDialog::getColor( ui->RoiHandlesButton->palette().background().color(), this ); if ( c.isValid() ) { m_AnchorColor = c; ui->RoiHandlesButton->setPalette(QPalette(m_AnchorColor)); MIL_INT anchorcolor = M_RGB888(c.red(),c.green(),c.blue()); MdispControl(m_MilDisplay, M_ROI_HANDLE_COLOR, anchorcolor); MdispControl(m_MilDisplay, M_UPDATE, M_NULL); } }
void ROIDialog::OnROIAnchorColorChange(GtkColorButton *widget, gpointer user_data) { ROIDialog* rd = (ROIDialog *) user_data; if(rd) { gtk_color_button_get_color(widget,&(rd->m_AnchorColor)); MIL_INT anchorcolor = M_RGB888(rd->m_AnchorColor.red>>8, rd->m_AnchorColor.green>>8, rd->m_AnchorColor.blue>>8); MdispControl(rd->m_MilDisplay, M_ROI_HANDLE_COLOR, anchorcolor); MdispControl(rd->m_MilDisplay, M_UPDATE, M_NULL); } }
void MdispGtkView::ChangeViewMode(long ViewMode,long ShiftValue) { if(m_MilDisplay) { //Apply view mode on display [CALL TO MIL] MdispControl(m_MilDisplay, M_VIEW_MODE, ViewMode); if(ViewMode == M_BIT_SHIFT) MdispControl(m_MilDisplay, M_VIEW_BIT_SHIFT, ShiftValue); //Check if control worked correctly before considering it as successful [CALL TO MIL] if(MdispInquire(m_MilDisplay, M_VIEW_MODE,M_NULL)==ViewMode) { //Make sure ViewMode Mode combo box shows current interpolation mode m_currentViewMode = ViewMode; m_currentShiftValue = ShiftValue; } } }
// Configura el display MIL de tal manera que se muestren las imagenes con la profundidad dada void ControlImagenes::DisplayBits(int nBitsProfundidad) { if (nBitsProfundidad == 8) { MdispControl(m_Mildisplay,M_VIEW_MODE,M_TRANSPARENT); } else if (nBitsProfundidad == 12) { MdispControl(m_Mildisplay,M_VIEW_MODE,M_BIT_SHIFT); MdispControl(m_Mildisplay,M_VIEW_BIT_SHIFT,4); //despreciamos los 4 bits menos significativos // MdispLut(m_Mildisplay, M_PSEUDO); //esto es necesario para que la intensidad no sea anormalmente elevada } else if (nBitsProfundidad == 16) { MdispControl(m_Mildisplay,M_VIEW_MODE,M_BIT_SHIFT); MdispControl(m_Mildisplay,M_VIEW_BIT_SHIFT,8); //despreciamos los 4 bits menos significativos // MdispLut(m_Mildisplay, M_PSEUDO); //esto es necesario para que la intensidad no sea anormalmente elevada } }
void MdispGtkView::ROIShow(bool on) { ///////////////////////////////////////////////////////////////////////// // MIL: Write code that will be executed when 'ROI Show ' // menu is clicked. State toggles. ///////////////////////////////////////////////////////////////////////// if(m_MilDisplay && m_isROISupported) { MdispControl(m_MilDisplay, M_ROI_SHOW, on?M_ENABLE:M_DISABLE); m_isInROIShowMode = on; } }
void MdispGtkView::ChangeQFactor(MIL_INT QFactor) { if(m_MilDisplay) { // Apply Q factor to display [CALL TO MIL] MdispControl(m_MilDisplay, M_Q_FACTOR, QFactor); // Check if control worked correctly before considering it successful [CALL TO MIL] if(MdispInquire(m_MilDisplay, M_Q_FACTOR, M_NULL) == QFactor) { m_currentQFactor = QFactor; } } }
void MdispGtkView::ChangeCompressionType(MIL_INT CompressionType) { if(m_MilDisplay) { // Apply compression type to display [CALL TO MIL] MdispControl(m_MilDisplay, M_COMPRESSION_TYPE, CompressionType); // Check if control worked correctly before considering it successful [CALL TO MIL] if(MdispInquire(m_MilDisplay, M_COMPRESSION_TYPE, M_NULL) == CompressionType) { m_currentCompressionType = CompressionType; } } }
void MdispGtkView::RestrictCursor(bool on) { ///////////////////////////////////////////////////////////////////////// // MIL: Write code that will be executed when 'Restrict Cursor' menu item is clicked ///////////////////////////////////////////////////////////////////////// if(m_MilDisplay) { MdispControl(m_MilDisplay, M_RESTRICT_CURSOR,on?M_ENABLE:M_DISABLE); // Check if control worked correctly before considering it successful [CALL TO MIL] MdispInquire(m_MilDisplay, M_RESTRICT_CURSOR, &m_currentRestrictCursor); } }
void MdispGtkView::ChangeInterpolationMode(long InterpolationMode) { if(m_MilDisplay) { //Apply interpolation mode on display [CALL TO MIL] MdispControl(m_MilDisplay, M_INTERPOLATION_MODE, InterpolationMode); //Check if control worked correctly before considering it as successful [CALL TO MIL] if(MdispInquire(m_MilDisplay, M_INTERPOLATION_MODE,M_NULL)==InterpolationMode) { //Make sure Interpolation Mode combo box shows current interpolation mode m_currentInterpolationMode = InterpolationMode; } } }
void MdispGtkView::NoTearing( bool on ) { ///////////////////////////////////////////////////////////////////////// // MIL: Write code that will be executed when 'No Tearing' button or menu is clicked ///////////////////////////////////////////////////////////////////////// // No Notearing in windowed mode in linux if(m_isWindowed) return; if(m_MilDisplay) { //Enable/disable No-Tearing mode on display [CALL TO MIL] MdispControl(m_MilDisplay, M_NO_TEARING, on ? M_ENABLE : M_DISABLE); //Check if it worked before considering it as enabled [CALL TO MIL] if(MdispInquire(m_MilDisplay, M_NO_TEARING, M_NULL) == on ? M_ENABLE : M_DISABLE) { m_isNoTearingEnabled = on; } } }
/*************************** ini_control_digitalizador ********************* Función para reservar memoria para los diferentes formatos de digitalizadores que se utilizarán en la toma de imágenes. Previamente, se comprueba que los parámetros iniciales son válidos para el formato y tipo de digitalizador reservado. Seguidamente se reserva el display y los buffers que se utilizan en el proceso de adquisición de imágenes. *****************************************************************************/ int ini_control_digitalizador(parametros *param) { char *fn = "ini_control_digitalizador - "; int i; paramAux = param; //para usar en otras funciones // SI DEFINO UN TAMAÑO DE DIGITALIZADOR DE ENFOQUE... (DIGITALIZADOR) // Reservo memoria para un nuevo display en el que se mostrarán los campos // recorridos y los que se han podido enfocar. if (param->Cam.formatoDig_e[0] != '\0' && strcmp(param->Cam.formatoDig, param->Cam.formatoDig_e) ) { // Configuro el digitalizador en formato enfoque if (M_digitalizador != M_NULL) libera_digitalizador(); if ( MdigAlloc (M_sistema, M_DEV0, param->Cam.formatoDig_e, M_DEFAULT, &M_digitalizador) == M_NULL ) { error_fatal("ini_control_digitalizador", "Formato incorrecto", 0); #if !defined (__BORLANDC__) putch('\a'); #endif return 1; } MdigInquire(M_digitalizador, M_SIZE_X, &limCam.anchoDig_e); if ( limCam.anchoDig_e > MAX_ANCHO_IMAGEN || limCam.anchoDig_e < param->Cam.anchoImagen_e ) { error_fatal(fn, "Error en los parámetros iniciales", 0); #if !defined (__BORLANDC__) putch('\a'); #endif return 1; } MdigInquire(M_digitalizador, M_SIZE_Y, &limCam.altoDig_e); if ( limCam.altoDig_e > MAX_ALTO_IMAGEN || limCam.altoDig_e < param->Cam.altoImagen_e ) { error_fatal(fn, "Error en los parámetros iniciales", 0); #if !defined (__BORLANDC__) putch('\a'); #endif return 1; } } // Configuro el digitalizador en formato normal. if (M_digitalizador != M_NULL) libera_digitalizador(); if ( MdigAlloc (M_sistema, M_DEV0, param->Cam.formatoDig, M_DEFAULT, &M_digitalizador) == M_NULL ) { error_fatal("ini_control_proceso_imagenes", "Formato incorrecto", 0); return 1; } MdigInquire(M_digitalizador, M_SIZE_X, &limCam.anchoDig); if ( limCam.anchoDig > MAX_ANCHO_IMAGEN || limCam.anchoDig < param->Cam.anchoImagen ) { error_fatal(fn, "Error en los parámetros iniciales", 0); #if !defined (__BORLANDC__) putch('\a'); #endif return 1; } MdigInquire(M_digitalizador, M_SIZE_Y, &limCam.altoDig); if ( limCam.altoDig > MAX_ALTO_IMAGEN || limCam.altoDig < param->Cam.altoImagen ) { error_fatal(fn, "Error en los parámetros iniciales", 0); #if !defined (__BORLANDC__) putch('\a'); #endif return 1; } // Si el formato del digitalizador de enfoque es el mismo que el de // captura normal, copiamos las dimensiones porque no se leyeron. if ( strcmp(param->Cam.formatoDig, param->Cam.formatoDig_e) == 0 ) { limCam.anchoDig_e = limCam.anchoDig; limCam.altoDig_e = limCam.altoDig; } // Compruebo los valores iniciales de brillo, ganancia y exposición. if ( info_digitalizador(M_digitalizador) ) { error_fatal(fn, "Error en los parámetros iniciales", 0); return 1; } // Se centra la camara en el caso de que se haya configurado un tamaño de toma diferente al maximo de la camara if ( configura_digitalizador(FORMATO_NORMAL) ) return 1; // Buffer auxiliar de PROFUNDIDAD_ACUMULACION bits para acumular valores. MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, PROFUNDIDAD_ACUMULACION+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC+M_GRAB, &M_imagen_acum); if ( M_imagen_acum == M_NULL ) { error_fatal(fn, "M_imagen_acum", 0); return 1; } // Obtenemos la profundidad de la camara MdigInquire(M_digitalizador, M_SIZE_BIT , ¶m->Cam.profundidad); if ( (BITS_CAMARA > 8 && param->Cam.profundidad <= 8) || (BITS_CAMARA <= 8 && param->Cam.profundidad > 8) ) { error_fatal(fn, "BITS_CAMARA (DEFINE en codigo) y profundidad camara no coherentes", 0); return 1; } //Si la profundidad no es de 8bit, hay que configurar el display. //El display siempre es de 8 bit if (param->Cam.profundidad == 16) { MdispControl(M_display_normal,M_VIEW_MODE,M_BIT_SHIFT); MdispControl(M_display_normal,M_VIEW_BIT_SHIFT,4); //despreciamos los 4 bits menos significativos MdispLut(M_display_normal, M_PSEUDO); //esto es necesario para que la intensidad no sea anormalmente elevada } // Reservamos los buffers donde se almacenarán y procesarán las imágenes. // M_imagen1 será el buffer que normalmente estará asociado al display_normal. // En modo VGA no permite grabar datos en el buffer. long nSD_size; MsysInquire(M_sistema,M_SYSTEM_DESCRIPTOR_SIZE,&nSD_size); char* systemDescriptor = new char[nSD_size]; MsysInquire(M_sistema,M_SYSTEM_DESCRIPTOR,systemDescriptor); if (systemDescriptor == M_SYSTEM_VGA) MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &M_imagen1 ); else MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_GRAB+M_PROC, &M_imagen1 ); delete [ ] systemDescriptor; if ( M_imagen1 == M_NULL) { error_fatal(fn, "M_imagen1", 0); return -1; } if ( M_imagen1 != M_NULL ) { // Seleccionamos el display para imagen normal, asociando el overlay. #if !defined (__BORLANDC__) configura_overlay(M_display_normal, M_imagen1, &M_overlay_normal, 1); #else configura_overlay(M_display_normal, M_imagen1, HWindow, &M_overlay_normal, 1); borra_buffer(M_imagen1, NEGRO, 0, 0, NULL, NULL); #endif /* */ if (param->Cam.anchoImagen != param->Cam.anchoImagen_e || param->Cam.altoImagen != param->Cam.altoImagen_e) { // Reservo un child buffer de M_imagen1 con el tamaño de enfoque. MbufChild2d(M_imagen1, (param->Cam.anchoImagen - param->Cam.anchoImagen_e) /2, (param->Cam.altoImagen- param->Cam.altoImagen_e) /2, param->Cam.anchoImagen_e, param->Cam.altoImagen_e, &M_centro_imagen); if (M_centro_imagen == M_NULL) { error_fatal(fn, "M_centro_imagen", 0); return -1; } } else M_centro_imagen = M_imagen1; } MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &M_imagen2 ); if ( M_imagen2 == M_NULL ) { error_fatal(fn, "M_imagen2", 0); return -1; } MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &M_imagen3); if ( M_imagen3 == M_NULL ) { error_fatal(fn, "M_imagen3", 0); return -1; } MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &M_imagen4); if ( M_imagen4 == M_NULL ) { error_fatal(fn, "M_imagen4", 0); return -1; } MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &M_imagen5); if ( M_imagen5 == M_NULL ) { error_fatal(fn, "M_imagen5", 0); return -1; } MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &M_imagen6); if ( M_imagen6 == M_NULL ) { error_fatal(fn, "M_imagen6", 0); return -1; } // Reservo memoria para los buffers utilizados en la adquisición // de las bandas y en la correccion de la iluminación. for (i=0; i < param->nBandas; i++) { MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &M_banda[i]); MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, 32+M_FLOAT, M_IMAGE+M_PROC, &M_correc_denom[i]); MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, 32+M_FLOAT, M_IMAGE+M_PROC, &M_correc_numer[i]); if ( M_banda[i] == M_NULL || M_correc_numer[i] == M_NULL || M_correc_denom[i] == M_NULL ) { error_fatal(fn, "M_banda", 0); return 1; } } //El resto de filtros no usados a NULL for (; i < MAX_FILTROS_DTA; i++) M_banda[i] = M_correc_numer[i] = M_correc_denom[i] = M_NULL; MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, 32+M_FLOAT, M_IMAGE+M_PROC, &M_correc_aux); if ( M_correc_aux == M_NULL ) { error_fatal(fn, "M_correc_aux", 0); return 1; } // SI DEFINO UN TAMAÑO DE DIGITALIZADOR DE ENFOQUE... (BUFFERS) // Reservo memoria para los buffers empleados durante el enfoque mediante la funcion determina_contraste2 if ( param->Cam.formatoDig_e[0] != '\0' ) { MbufAlloc2d(M_sistema, param->Cam.anchoImagen_e, param->Cam.altoImagen_e, param->Cam.profundidad+M_UNSIGNED, M_IMAGE+M_DISP+M_GRAB+M_PROC, &M_enfoque); if ( M_enfoque == M_NULL ) { error_fatal(fn, "M_enfoque", 0); return 1; } } return 0; }
ControlImagenes::ControlImagenes() { //Inicilizacion // m_Milsistema = M_NULL; m_Milaplicacion = M_NULL; m_Mildisplay = M_NULL; m_Miloverlay = M_NULL; m_lut_overlay = M_NULL; m_numImagenes = 0; m_nAnchoImagen = -1; m_nAltoImagen = -1; for (int i=0;i<MAX_NUM_IMAGENES;i++) m_Milimagen[i] = M_NULL; m_MilRGB = M_NULL; M_Clasificacion = M_NULL; m_bufClasificacionSelectiva = NULL; m_bDefiniendoArea = false; m_bPintandoRect = false; MappAlloc(M_DEFAULT, &m_Milaplicacion); // Selecciono la aplicación MIL. if ( m_Milaplicacion == M_NULL ) { AfxMessageBox("Error: No se pudo inicilizar MIL", MB_ICONERROR | MB_OK); } // Pregunto al sistema la versión de la librería de control de proceso de imagen //MappInquire(M_VERSION, &m_Milversion); // pruebas MIL 8 // MsysAlloc(M_SYSTEM_METEOR_II_1394, M_DEV0, M_DEFAULT, &M_sistema); // Selecciono un sistema hardware // if ( M_sistema == M_NULL ) { // AfxMessageBox("Error: No se pudo inicilizar MIL", MB_ICONERROR | MB_OK); // } // Display normal para las imágenes adquiridas y procesadas. MdispAlloc(M_DEFAULT_HOST, M_DEFAULT, "M_DEFAULT", M_WINDOWED + M_GDI_OVERLAY, &m_Mildisplay); if ( m_Mildisplay == M_NULL ) { AfxMessageBox("Error: No se pudo inicilizar MIL", MB_ICONERROR | MB_OK); } // El texto tiene color de fondo transparente MgraControl(M_DEFAULT, M_BACKGROUND_MODE, M_TRANSPARENT); // OVERLAY (diferente para MIL 8 y anteriores if (M_MIL_CURRENT_VERSION >= 8.0) { // Inicializar colores para pintar areas m_listaColor[NEGRO_POS] = M_RGB888(NEGRO_R,NEGRO_G,NEGRO_B); m_listaColor[MARRON_POS] = M_RGB888(MARRON_R,MARRON_G,MARRON_B); m_listaColor[ROJO_POS] = M_RGB888(ROJO_R,ROJO_G,ROJO_B); m_listaColor[CYAN_POS] = M_RGB888(CYAN_R,CYAN_G,CYAN_B); m_listaColor[NARANJA_POS] = M_RGB888(NARANJA_R,NARANJA_G,NARANJA_B); m_listaColor[VERDE_POS] = M_RGB888(VERDE_R,VERDE_G,VERDE_B); m_listaColor[AZUL_POS] = M_RGB888(AZUL_R,AZUL_G,AZUL_B); m_listaColor[MORADO_POS] = M_RGB888(MORADO_R,MORADO_G,MORADO_B); m_listaColor[GRIS_POS] = M_RGB888(GRIS_R,GRIS_G,GRIS_B); m_listaColor[ORO_POS] = M_RGB888(ORO_R,ORO_G,ORO_B); m_listaColor[ROSA_POS] = M_RGB888(ROSA_R,ROSA_G,ROSA_B); MdispControl(m_Mildisplay, M_OVERLAY, M_ENABLE); // Establezco TRANSPARENTE como color transparente MdispControl(m_Mildisplay, M_TRANSPARENT_COLOR, TRANSPARENTE); //Tipo de interpolacion para el redimensionamiento de la imagen en el display //Si se activa en MIL 8, quedan lineas de color transparernte en el overlay cuando el zoom no es 1 //MdispControl(m_Mildisplay, M_INTERPOLATION_MODE, M_NEAREST_NEIGHBOR); } else { // Inicializar colores para pintar areas m_listaColor[0] = NEGRO ; m_listaColor[1] = ROJO_OSC ; m_listaColor[2] = ROJO ; m_listaColor[3] = CYAN ; m_listaColor[4] = AMARILLO; m_listaColor[5] = VERDE ; m_listaColor[6] = AZUL ; m_listaColor[7] = MAGENTA_OSC ; m_listaColor[8] = GRIS ; m_listaColor[9] = AMARILLO_OSC ; m_listaColor[10] = GRIS_CLA ; // LUT MbufAllocColor(M_DEFAULT_HOST, 3L, 256L, 1L, 8L+M_UNSIGNED, M_LUT, &m_lut_overlay); if ( m_lut_overlay == M_NULL) { AfxMessageBox("Error: No se pudo inicilizar MIL", MB_ICONERROR | MB_OK); } crea_LUT_overlay(m_lut_overlay, 0); // Genera LUT color y corrección de gamma configura_overlay(m_Mildisplay, M_NULL, &m_Miloverlay, 1); // repartido entre aqui y CargarImagen // M_NULL, antes ponia M_imagen1 que ya no esta disponible en Analisis, seguramente falle // Asocio la LUT de pseudo-color al display de overlay MdispControl(m_Mildisplay, M_OVERLAY_LUT, m_lut_overlay); // Modifico la configuración del display: m_Mildisplay_normal. // - Deshabilito el menú de tareas. // - Deshabilito la barra del título. // - Fijo la posición de la ventana en 0,0. MdispControl(m_Mildisplay, M_WINDOW_MENU_BAR, M_DISABLE); MdispControl(m_Mildisplay, M_WINDOW_TITLE_BAR, M_DISABLE); MdispControl(m_Mildisplay, M_WINDOW_INITIAL_POSITION_X, 0 ); MdispControl(m_Mildisplay, M_WINDOW_INITIAL_POSITION_Y, 0 ); // Establezco TRANSPARENTE como color transparente MdispOverlayKey(m_Mildisplay, M_KEY_ON_COLOR, M_EQUAL, 0xff, TRANSPARENTE); } // Bitmap de fondo para poner siempre que no haya mas imagenes BYTE bBits[] = {0xd8,0xe9,0xec}; m_backgound_bitmap.CreateBitmap(1,1,1,32,bBits); }
void MdispGtkView::InitializeOverlay() { MIL_TEXT_CHAR chText[80]; // Initialize overlay if not already done if ((!m_isOverlayInitialized) && (m_MilDisplay)) { //Only do it on a valid windowed display [CALL TO MIL] if (m_MilImage && m_MilDisplay ) { // Prepare overlay buffer // //////////////////////////// // Enable display overlay annotations. MdispControl(m_MilDisplay, M_OVERLAY, M_ENABLE); // Inquire the Overlay buffer associated with the displayed buffer [CALL TO MIL] MdispInquire(m_MilDisplay, M_OVERLAY_ID, &m_MilOverlayImage); // Clear the overlay to transparent. MdispControl(m_MilDisplay, M_OVERLAY_CLEAR, M_DEFAULT); // Disable the overlay display update to accelerate annotations. MdispControl(m_MilDisplay, M_OVERLAY_SHOW, M_DISABLE); // Draw MIL monochrome overlay annotation * //***************************************** // Inquire MilOverlayImage size x and y [CALL TO MIL] long imageWidth = MbufInquire(m_MilOverlayImage,M_SIZE_X,M_NULL); long imageHeight = MbufInquire(m_MilOverlayImage,M_SIZE_Y,M_NULL); // Set graphic text to transparent background. [CALL TO MIL] MgraControl(M_DEFAULT, M_BACKGROUND_MODE, M_TRANSPARENT); // Set drawing color to white. [CALL TO MIL] MgraColor(M_DEFAULT, M_COLOR_WHITE); // Print a string in the overlay image buffer. [CALL TO MIL] MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5, " -------------------- "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5+25, " - MIL Overlay Text - "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth/9, imageHeight/5+50, " -------------------- "); // Print a green string in the green component overlay image buffer. [CALL TO MIL] MgraColor(M_DEFAULT, M_COLOR_GREEN); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5, " -------------------- "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5+25, " - MIL Overlay Text - "); MgraText(M_DEFAULT, m_MilOverlayImage, imageWidth*11/18, imageHeight/5+50, " -------------------- "); // Draw GDI color overlay annotation * //************************************ // Disable hook to MIL error because control might not be supported MappControl(M_ERROR_HOOKS, M_DISABLE); // Create a device context to draw in the overlay buffer with GDI. [CALL TO MIL] MbufControl(m_MilOverlayImage, M_XPIXMAP_ALLOC, M_COMPENSATION_ENABLE); // Reenable hook to MIL error MappControl(M_ERROR_HOOKS, M_ENABLE); // Retrieve the XPIXMAP of the overlay [CALL TO MIL] Pixmap XPixmap = (Pixmap)MbufInquire(m_MilOverlayImage, M_XPIXMAP_HANDLE, M_NULL); /* convert it to gdkpixmap */ GdkPixmap *gdkpixmap = gdk_pixmap_foreign_new(XPixmap); if(gdkpixmap) { GdkPoint Hor[2]; GdkPoint Ver[2]; GdkColor color[3]; GdkFont *font = NULL; font = gdk_font_load ("-misc-*-*-r-*-*-*-140-*-*-*-*-*-1"); int i; /* get graphic context from pixmap*/ GdkGC *gc = gdk_gc_new(gdkpixmap); /* allocate colors */ gdk_color_parse("blue",&color[0]); gdk_color_parse("red",&color[1]); gdk_color_parse("yellow",&color[2]); for(i=0;i<3;i++) gdk_color_alloc(gdk_colormap_get_system(), &color[i]); /* set the foreground to our color */ gdk_gc_set_foreground(gc, &color[0]); // Draw a blue cross in the overlay buffer. Hor[0].x = 0; Hor[0].y = imageHeight/2; Hor[1].x = imageWidth; Hor[1].y = imageHeight/2; gdk_draw_lines(gdkpixmap,gc,Hor,2); Ver[0].x = imageWidth/2; Ver[0].y = 0; Ver[1].x = imageWidth/2; Ver[1].y = imageHeight; gdk_draw_lines(gdkpixmap,gc,Ver,2); // Write Red text in the overlay buffer. MosStrcpy(chText, 80, "X Overlay Text "); gdk_gc_set_foreground(gc, &color[1]); gdk_draw_string(gdkpixmap, font, gc, imageWidth*3/18, imageHeight*4/6, chText); // Write Yellow text in the overlay buffer. gdk_gc_set_foreground(gc, &color[2]); gdk_draw_string(gdkpixmap, font, gc, imageWidth*12/18, imageHeight*4/6, chText); /* flush */ gdk_display_flush(gdk_display_get_default()); /* Free graphic context.*/ g_object_unref(gc); // Delete created Pixmap. [CALL TO MIL] MbufControl(m_MilOverlayImage, M_XPIXMAP_FREE, M_DEFAULT); // Signal MIL that the overlay buffer was modified. [CALL TO MIL] MbufControl(m_MilOverlayImage, M_MODIFIED, M_DEFAULT); } // Now that overlay buffer is correctly prepared, we can show it [CALL TO MIL] MdispControl(m_MilDisplay, M_OVERLAY_SHOW, M_ENABLE); // Overlay is now initialized m_isOverlayInitialized = true; } } }
void MdispGtkView::Initialize() { // Allocate a display [CALL TO MIL] MdispAlloc(((MdispGtkApp*)dispGtkApp())->m_MilSystem, M_DEFAULT, "M_DEFAULT", M_DEFAULT, &m_MilDisplay); if(m_MilDisplay) { MIL_INT DisplayType = MdispInquire(m_MilDisplay, M_DISPLAY_TYPE, M_NULL); // Check display type [CALL TO MIL] if((DisplayType&(M_WINDOWED|M_EXCLUSIVE)) !=M_WINDOWED) m_isWindowed = false; if(DisplayType&(M_EXCLUSIVE)) m_isExclusive = true; // ROI are supported with windowed display m_isROISupported = (DisplayType&M_WINDOWED) != 0; // Initially set interpolation mode and view mode to default ChangeInterpolationMode(M_DEFAULT); ChangeViewMode(M_DEFAULT); if(m_isWindowed) { #if USE_ANNOTATION // The connection to the X display must be given to Mil so it // can update the window when ROI is enabled MdispControl(m_MilDisplay,M_WINDOW_ANNOTATIONS,M_PTR_TO_DOUBLE(GDK_WINDOW_XDISPLAY(m_window->window))); #else m_isROISupported = false; #endif } if(m_isROISupported) { // Set ROI-show mode. ROIShow(m_isInROIShowMode); // Install hooks for ROI info in status bar and to keep current status // in toolbar MdispHookFunction(m_MilDisplay, M_ROI_CHANGE, ROIChangeFct, (void*)this); MdispHookFunction(m_MilDisplay, M_ROI_CHANGE_END, ROIChangeEndFct, (void*)this); } if(IsNetworkedSystem()) { // Check compression type [CALL TO MIL] MdispInquire(m_MilDisplay, M_COMPRESSION_TYPE, &m_currentCompressionType); // Check asynchronous mode [CALL TO MIL] m_isInAsynchronousMode = (MdispInquire(m_MilDisplay, M_ASYNC_UPDATE, M_NULL) == M_ENABLE); // Check asynchronous frame rate [CALL TO MIL] MdispInquire(m_MilDisplay, M_UPDATE_RATE_MAX, &m_currentAsynchronousFrameRate); // Check Q factor [CALL TO MIL] MdispInquire(m_MilDisplay, M_Q_FACTOR, &m_currentQFactor); } if(m_isExclusive) { MdispInquire(m_MilDisplay, M_RESTRICT_CURSOR, &m_currentRestrictCursor); } //Select the buffer from it's display object and given window [CALL TO MIL] MdispSelectWindow(m_MilDisplay, m_MilImage, m_isWindowed?GDK_WINDOW_XID(m_window->window):0); } // Hook a function to mouse-movement event, to update cursor position in status bar. MdispHookFunction(m_MilDisplay, M_MOUSE_MOVE, MouseFct, (void*)this); ///////////////////////////////////////////////////////////////////////// // MIL: Code that will be executed when a view is first attached to the document ///////////////////////////////////////////////////////////////////////// }