コード例 #1
0
bool MdispGtkView::saveROIAs(const char *filename)
   {
   /////////////////////////////////////////////////////////////////////////
   // MIL: Get current ROI in buffer-related coordinates.
   /////////////////////////////////////////////////////////////////////////
   MIL_INT OffsetX   = MdispInquire(m_MilDisplay, M_ROI_BUFFER_OFFSET_X, M_NULL);
   MIL_INT OffsetY   = MdispInquire(m_MilDisplay, M_ROI_BUFFER_OFFSET_Y, M_NULL);
   MIL_INT SizeX     = MdispInquire(m_MilDisplay, M_ROI_BUFFER_SIZE_X, M_NULL);
   MIL_INT SizeY     = MdispInquire(m_MilDisplay, M_ROI_BUFFER_SIZE_Y, M_NULL);
      
   /////////////////////////////////////////////////////////////////////////
   // MIL: Create a child of the selected buffer, with the ROI coordinates.
   /////////////////////////////////////////////////////////////////////////
   MIL_ID ChildBuffer = MbufChildColor2d(m_MilImage,
                                         M_ALL_BANDS, 
                                         OffsetX, 
                                         OffsetY, 
                                         SizeX, 
                                         SizeY,
                                         M_NULL);

   /////////////////////////////////////////////////////////////////////////
   // MIL: Save the buffer in the path given by the user.
   /////////////////////////////////////////////////////////////////////////
   MbufSave(filename, ChildBuffer);
   MbufFree(ChildBuffer);
   return true;
   }
コード例 #2
0
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); 
            } 
         } 
      }
   }
コード例 #3
0
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;
            }
         }
      }
   }
コード例 #4
0
RoiPrefsDlg::RoiPrefsDlg(QWidget *parent, MIL_ID MilDisplay) :
    QDialog(parent),
    ui(new Ui::RoiPrefsDlg),
    m_MilDisplay(MilDisplay)
{
    QPalette palette;

    ui->setupUi(this);

    MIL_INT linecolor = MdispInquire(m_MilDisplay, M_ROI_LINE_COLOR, M_NULL);
    MIL_INT anchorcolor= MdispInquire(m_MilDisplay, M_ROI_HANDLE_COLOR, M_NULL);

    m_LineColor.setRgb(M_RGB888_r(linecolor),
                       M_RGB888_g(linecolor),
                       M_RGB888_b(linecolor));

    m_AnchorColor.setRgb(M_RGB888_r(anchorcolor),
                         M_RGB888_g(anchorcolor),
                         M_RGB888_b(anchorcolor));

    palette.setColor(ui->RoiLineButton->backgroundRole(), m_LineColor);
    ui->RoiLineButton->setPalette(palette);
    ui->RoiLineButton->setAutoFillBackground(true);
    ui->RoiLineButton->setFocusPolicy(Qt::NoFocus);

    ui->RoiHandlesButton->setPalette(QPalette(m_AnchorColor));
    ui->RoiHandlesButton->setAutoFillBackground(true);
    ui->RoiHandlesButton->setFocusPolicy(Qt::NoFocus);

    connect(ui->RoiOkButton, SIGNAL(clicked()), SLOT(close()));

}
コード例 #5
0
MIL_INT MFTYPE ROIChangeFct(MIL_INT /*HookType*/, MIL_ID /*EventID*/, void MPTYPE *UserDataPtr)
   {
   MdispGtkView *pCurrentView = (MdispGtkView *)UserDataPtr;
   if(pCurrentView)
      {
      MIL_ID DisplayID  = pCurrentView->m_MilDisplay;
      MIL_INT OffsetX   = MdispInquire(DisplayID, M_ROI_BUFFER_OFFSET_X, M_NULL);
      MIL_INT OffsetY   = MdispInquire(DisplayID, M_ROI_BUFFER_OFFSET_Y, M_NULL);
      MIL_INT SizeX     = MdispInquire(DisplayID, M_ROI_BUFFER_SIZE_X, M_NULL);
      MIL_INT SizeY     = MdispInquire(DisplayID, M_ROI_BUFFER_SIZE_Y, M_NULL);
      pCurrentView->UpdateStatusBarWithROI(OffsetX, OffsetY, SizeX, SizeY);
      }
   return 0;
   }
コード例 #6
0
bool MdispGtkView::IsFileSaveRoiAsEnabled()
   {
   /////////////////////////////////////////////////////////////////////////
   // MIL: If no ROI exist, we do not allow user to select this item.
   /////////////////////////////////////////////////////////////////////////
   if(m_MilDisplay)
      {
      if(MdispInquire(m_MilDisplay, M_ROI_BUFFER_SIZE_X, M_NULL)&&
         MdispInquire(m_MilDisplay, M_ROI_BUFFER_SIZE_Y, M_NULL))
         {
         return true;
         }
      }
   return false;
   }
コード例 #7
0
// interfaz con Clasificacion para clasificar la imagen m_Milimagen (ya cargada y perteneciente a ControlImagen)
// devuelve false, si ha habido un error o si ya se habia clasificado y unicamente se ha mostrado la imagen ya clasificada
bool ControlImagenes::Clasificar(CStatic*	pDisplay, list<CMineralClasificado> &listClasificados, unsigned int& nCountOscuros, CRect* pRect, double dRefMin)
{
    if (M_Clasificacion == M_NULL) // hace falta clasificar de nuevo, no se hizo con anterioridad
        if (!theApp.clasificacion.CargarImagenes(&m_Milimagen[1],m_numImagenes,pRect)) // nos saltamos la banda pancromatica (no usada)
            return false;

    if (pDisplay!=NULL)
    {
        MIL_ID selected;
        MdispInquire(m_Mildisplay,M_SELECTED,&selected);
        if (selected!=M_NULL)
            MdispDeselect(m_Mildisplay,selected);

        DisplayBits(8); //para que el display muestre las imagenes de la profundidad leida
        if (!theApp.clasificacion.InicializaDisplay(pDisplay,m_Mildisplay,M_Clasificacion,M_Confiabilidad,M_Distancia))
        {
           ASSERT(m_bufClasificacionSelectiva != NULL);
           return false;
        }

        if (m_bufClasificacionSelectiva == NULL)
           m_bufClasificacionSelectiva = new BYTE[m_nAnchoImagen*m_nAltoImagen];//buffer para la imagen de salida (clasificada selectivamente) 
    }

    if (!theApp.clasificacion.Clasificar(listClasificados,nCountOscuros,theApp.m_dEscalaReflectancia, theApp.m_nBitsProfundidad, dRefMin))
        return false;

    return true;
}
コード例 #8
0
void ControlImagenes::Distancia(CStatic&	m_control)
{
    MIL_ID selected;
    MdispInquire(m_Mildisplay,M_SELECTED,&selected);
    if (selected!=M_NULL)
        MdispDeselect(m_Mildisplay,selected);

    MdispSelectWindow(m_Mildisplay, M_Distancia, m_control);
}
コード例 #9
0
void MdispGtkView::UpdateROIWithCurrentState()
   {
   if(m_MilDisplay)
      {
      if(MdispInquire(m_MilDisplay, M_ROI_DEFINE, M_NULL) == M_STOP)
         m_isInROIDefineMode = false;
      else
         m_isInROIDefineMode = true;
      }
   }
コード例 #10
0
void ControlImagenes::Confiabilidad(CStatic&	m_control)
{
    MIL_ID selected;
    MdispInquire(m_Mildisplay,M_SELECTED,&selected);
    if (selected!=M_NULL)
        MdispDeselect(m_Mildisplay,selected);

    DisplayBits(8); //para que el display muestre las imagenes en profundidad 8 bit
    MdispSelectWindow(m_Mildisplay, M_Confiabilidad, m_control);
}
コード例 #11
0
gboolean MdispGtkView::timerEvent(gpointer user_data)
   {
   MdispGtkView* pCurrentView = (MdispGtkView *) user_data;
   if(pCurrentView && pCurrentView->m_MilDisplay)
      {
      MIL_DOUBLE CurrentFrameRate = M_NULL;
      MdispInquire(pCurrentView->m_MilDisplay, M_UPDATE_RATE, &CurrentFrameRate);
      g_signal_emit(G_OBJECT(pCurrentView->m_cf->Window()), pCurrentView->m_cf->frameRateChangedSignal(), 0, CurrentFrameRate);
      }
   return true;
   }
コード例 #12
0
// Se reserva memoria, se carga y se presenta la imagen "nomFich"
// Se presupone que no hay otra imagen cargada con el mismo numero de filtro ("numFiltro")
//  m_control es el control al dialogo
//  bMostrar indica si debe de mostrarse la imagen en pantalla o solo cargar la imagen en memoria
// Se inicializa M_overlay_normal
// Se deja el zoom a 0.5
bool ControlImagenes::CargarImagen(char* nomFich, CStatic&	m_control, int numFiltro, bool bMostrar)
{

	// Comprobaciones
	struct stat stFileInfo;
	if (stat(nomFich,&stFileInfo) != 0)
		return false;
    if (m_Milimagen[numFiltro-1] != NULL)
        return false;

    long lSizeX, lSizeY;
    MbufDiskInquire(nomFich,M_SIZE_X, &lSizeX);
    MbufDiskInquire(nomFich,M_SIZE_Y, &lSizeY);
    MbufAlloc2d(M_DEFAULT_HOST, lSizeX,lSizeY, 16 + M_UNSIGNED, M_IMAGE + M_DISP + M_PROC, &m_Milimagen[numFiltro-1]);
    if (MbufImport(nomFich,M_TIFF,M_LOAD,M_NULL,&m_Milimagen[numFiltro-1]) == M_NULL)
//    if (MbufImport(nomFich,M_TIFF,M_RESTORE,M_DEFAULT_HOST,&m_Milimagen[numFiltro-1]) == M_NULL)
        return false;
    if (m_Milimagen[numFiltro-1] == NULL)
        return false;

    m_numImagenes++;

	if (bMostrar)
	{
		MdispSelectWindow(m_Mildisplay,m_Milimagen[numFiltro-1],m_control);
		// Inicializar Overlay la primera vez que se carga una imagen
		// Esto se hace aqui porque no funciona si no hay un buffer asociado con el display
		// ha de usarse la variable global M_overlay_normal para que funcionen las funciones graficas
		if (M_overlay_normal == M_NULL)
		{
			MdispInquire(m_Mildisplay, M_OVERLAY_ID, &M_overlay_normal);

			// Relleno el buffer overlay con el color TRANSPARENTE
//			MbufClear(M_overlay_normal, TRANSPARENTE );
		}
        // TRUCO para evitar que los rectangulos se pinten con un reborde negro. Pero la carga de imagenes es mas lenta
        // Se deja el zoom a 0.5
        // Los rectangulos se pintan con un reborde negro cuando el zoom esta entre 0.5 y 1 en MIL 8
        // por razones desconocidas. Este truco funciona, pero tampoco se sabe porque
//        MdispZoom(m_Mildisplay, 0.5, 0.5);
        //En la funcion llamante, se debe actualizar correctamente el zoom
	}
    // Solo una vez cada vez que se cargan todas las imagenes
    if (numFiltro == 2)
    {
        // Recuperamos las dimensiones de la imagen
        MbufInquire(m_Milimagen[1],M_SIZE_X,&m_nAnchoImagen);
        MbufInquire(m_Milimagen[1],M_SIZE_Y,&m_nAltoImagen);
	}

    return true;
}
コード例 #13
0
// Se presenta la imagen (previamente cargada) correspondiente al numero de Filtro "numFIltro"
bool ControlImagenes::MostrarImagen(int numFiltro, CStatic&	m_control)
{

    MIL_ID selected;
    MdispInquire(m_Mildisplay,M_SELECTED,&selected);
    if (selected!=M_NULL)
        MdispDeselect(m_Mildisplay,selected);

    DisplayBits(theApp.m_nBitsProfundidad); //para que el display muestre las imagenes de la profundidad de la imagen (puede que no estuviese si se estaba presentando la imagen de clasificacion)

    MdispSelectWindow(m_Mildisplay,m_Milimagen[numFiltro-1],m_control);
    return true;

}
コード例 #14
0
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;
         }
      }
   }
コード例 #15
0
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;
         }
      }
   }
コード例 #16
0
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;
         }
      }
   }
コード例 #17
0
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);

      }
   }
コード例 #18
0
void ControlImagenes::EliminarTodas()
{
    if (M_overlay_normal != M_NULL)
    {
        MbufClear(M_overlay_normal, TRANSPARENTE );// Relleno el buffer overlay con el color TRANSPARENTE
        M_overlay_normal = M_NULL;
    }


    MIL_ID selected;
    MdispInquire(m_Mildisplay,M_SELECTED,&selected);
    if (selected!=M_NULL)
        MdispDeselect(m_Mildisplay,selected);

    for (int i=0;i<MAX_NUM_IMAGENES;i++)
    {
        if (m_Milimagen[i] != M_NULL)
        {
            MbufFree(m_Milimagen[i]);
            m_Milimagen[i] = M_NULL;
        }
    }
    m_numImagenes = 0;

    //Liberamos RGB
    if (m_MilRGB != M_NULL)
    {
        MbufFree(m_MilRGB);
        m_MilRGB = M_NULL;
    }

    //Liberamos imagen identificacion
    if (M_Clasificacion != M_NULL)
    {
        MbufFree(M_Clasificacion);
        M_Clasificacion = M_NULL;
    }
    if (m_bufClasificacionSelectiva != NULL)
    {
        delete [] m_bufClasificacionSelectiva;
        m_bufClasificacionSelectiva = NULL;
    }
    theApp.clasificacion.Liberar();
}
コード例 #19
0
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;
         }
      }
   }
コード例 #20
0
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;
         }
      }
   }   
コード例 #21
0
ファイル: roidlg.cpp プロジェクト: DayStarEngineering/CDH
ROIDialog::ROIDialog(MIL_INT MilDisplay):m_MilDisplay(MilDisplay)
   {
   GtkWidget *pickerLine;
   GtkWidget *pickerAnchor;
   GtkWidget *closeButton;
   GtkWidget *vbox;
   GtkWidget *hbox;
   GtkWidget *label;
   
   MIL_INT linecolor = MdispInquire(m_MilDisplay, M_ROI_LINE_COLOR, M_NULL);
   MIL_INT anchorcolor= MdispInquire(m_MilDisplay, M_ROI_HANDLE_COLOR, M_NULL);
   
   m_LineColor.red   = M_RGB888_R(linecolor)<<8;
   m_LineColor.green = M_RGB888_G(linecolor)<<8;
   m_LineColor.blue  = M_RGB888_B(linecolor)<<8;

   m_AnchorColor.red   = M_RGB888_R(anchorcolor)<<8;
   m_AnchorColor.green = M_RGB888_G(anchorcolor)<<8;
   m_AnchorColor.blue  = M_RGB888_B(anchorcolor)<<8;

   m_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW(m_window), "ROI Preferences");
			     
   gtk_container_set_border_width (GTK_CONTAINER (m_window), 0);

   vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (m_window), vbox);
      
   label = gtk_label_new ("Color :");
   gtk_container_add (GTK_CONTAINER (vbox), label);

   hbox = gtk_hbox_new (FALSE, 8);
   gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
   gtk_container_add (GTK_CONTAINER (vbox), hbox);
      
   label = gtk_label_new ("Line Color");
   gtk_container_add (GTK_CONTAINER (hbox), label);

   pickerLine = gtk_color_button_new ();
   gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pickerLine), TRUE);
   gtk_container_add (GTK_CONTAINER (hbox), pickerLine);

   gtk_color_button_set_color(GTK_COLOR_BUTTON(pickerLine),&m_LineColor);
      
   hbox = gtk_hbox_new (FALSE, 8);
   gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
   gtk_container_add (GTK_CONTAINER (vbox), hbox);

   label = gtk_label_new ("Anchor Color");
   gtk_container_add (GTK_CONTAINER (hbox), label);

   pickerAnchor = gtk_color_button_new ();
   gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pickerAnchor), TRUE);
   gtk_container_add (GTK_CONTAINER (hbox), pickerAnchor);
   
   gtk_color_button_set_color(GTK_COLOR_BUTTON(pickerAnchor),&m_AnchorColor);

   closeButton = gtk_button_new_with_label("Close");
   gtk_container_add (GTK_CONTAINER (vbox), closeButton);
   
   //signals
   g_signal_connect (closeButton,"clicked",G_CALLBACK(ROIDialog::OnClose),this);
   g_signal_connect (pickerAnchor,"color-set",G_CALLBACK(ROIDialog::OnROIAnchorColorChange),this);
   g_signal_connect (pickerLine,"color-set",G_CALLBACK(ROIDialog::OnROILineColorChange),this);
   g_signal_connect (m_window, "destroy",  G_CALLBACK(ROIDialog::OnDestroy), this);
  
   }
コード例 #22
0
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
   /////////////////////////////////////////////////////////////////////////
   }
コード例 #23
0
// Calcula las imagenes monocromas para R, G y B segun los porcentajes dados, 
// reservando memoria y presentando la imagen RGB
// Devuelve true si se ha realizado el calculo, false si no (porque ya se realizó antes)
bool ControlImagenes::MostrarImagenRGB(int arrFiltroPorcentajesR[MAX_NUM_IMAGENES], 
                                       int arrFiltroPorcentajesG[MAX_NUM_IMAGENES], 
                                       int arrFiltroPorcentajesB[MAX_NUM_IMAGENES],
                                       CStatic&	m_control,
                                       int nTotalR,int nTotalG,int nTotalB,
                                       bool bModificado)
{

    MIL_ID selected;
    MdispInquire(m_Mildisplay,M_SELECTED,&selected);
    if (selected!=M_NULL)
        MdispDeselect(m_Mildisplay,selected);

    DisplayBits(8); //para que el display muestre las imagenes en profundidad 8 bit

    // Si es la primera vez, reservar la memoria de la imagen RGB
    if (m_MilRGB == M_NULL)
        MbufAllocColor(M_DEFAULT_HOST, 3, m_nAnchoImagen, m_nAltoImagen, 8+M_UNSIGNED, M_IMAGE+M_DISP, &m_MilRGB); //16 por si las imagenes estan en 16bit
    else if (!bModificado)
    {
        MdispSelectWindow(m_Mildisplay,m_MilRGB,m_control);
        return false;
    }


    unsigned short* pBuffImagen;    //auxiliar para volcar cada imagen de cada filtro, 16 bit
    unsigned char* pRed;           // auxiliar para calcular la banda de color (8 bit)
    unsigned char* pGreen;         // auxiliar para calcular la banda de color (8 bit)
    unsigned char* pBlue;          // auxiliar para calcular la banda de color (8 bit)

    pBuffImagen = (unsigned short*)calloc(m_nAnchoImagen*m_nAltoImagen, sizeof(unsigned short));
    pRed = (unsigned char*)calloc(m_nAnchoImagen*m_nAltoImagen, sizeof(unsigned char));
    pGreen = (unsigned char*)calloc(m_nAnchoImagen*m_nAltoImagen, sizeof(unsigned char));
    pBlue = (unsigned char*)calloc(m_nAnchoImagen*m_nAltoImagen, sizeof(unsigned char));

    for (int i= 0; i<MAX_NUM_IMAGENES;i++)
    {
        // Cargar buffers de filtros solo si se necesita en alguna de las bandas
        if (arrFiltroPorcentajesR[i] != 0 || arrFiltroPorcentajesG[i] != 0 || arrFiltroPorcentajesB[i] != 0)
        {
            MbufGet(m_Milimagen[i],pBuffImagen);

            //Acumular el pocentaje adecuado de este filtro en cada color
            if(arrFiltroPorcentajesR[i] != 0)
            {
                Acumular(pRed, pBuffImagen, ((double)arrFiltroPorcentajesR[i])/nTotalR, m_nAnchoImagen*m_nAltoImagen);
            }
            if(arrFiltroPorcentajesG[i] != 0)
            {
                Acumular(pGreen, pBuffImagen, ((double)arrFiltroPorcentajesG[i])/nTotalG, m_nAnchoImagen*m_nAltoImagen);
            }
            if(arrFiltroPorcentajesB[i] != 0)
            {
                Acumular(pBlue, pBuffImagen, ((double)arrFiltroPorcentajesB[i])/nTotalB, m_nAnchoImagen*m_nAltoImagen);
            }

        }
    }


    // Volcar el array auxiliar calculado al color correspondiente
    MbufPutColor(m_MilRGB,M_SINGLE_BAND,M_BLUE/*2*/,pBlue);
    MbufPutColor(m_MilRGB,M_SINGLE_BAND,M_GREEN/*1*/,pGreen);
    MbufPutColor(m_MilRGB,M_SINGLE_BAND,M_RED/*0*/,pRed);

    free(pBuffImagen);
    free(pBlue);
    free(pGreen);
    free(pRed);

    // Mostar la imagen en color
    MdispSelectWindow(m_Mildisplay,m_MilRGB,m_control);
	// Inicializar Overlay la primera vez que se carga una imagen
	// Esto se hace aqui porque no funciona si no hay un buffer asociado con el display
	// ha de usarse la variable global M_overlay_normal para que funcionen las funciones graficas
    // y porque puede ser que no se haya hecho al cargar las imagenes pancromaticas (en el caso
    // de que la primera imagen mostrada sea la pancromatica, ver CAnalisisDlg::AbrirTodas y CargarImagen)
	if (M_overlay_normal==NULL)
	{
		MdispInquire(m_Mildisplay, M_OVERLAY_ID, &M_overlay_normal);

		// Relleno el buffer overlay con el color TRANSPARENTE
		MbufClear(M_overlay_normal, TRANSPARENTE );
	}

    return true;
}
コード例 #24
0
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;
         }
      }
   }