Пример #1
0
void CFormTomaUnica::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
    if (nStatus == 0)
    {
        if (bShow == TRUE)
        {
            MdispSelectWindow(M_display_normal,M_imagen1,m_imagen);

            // Leemos el ratio configurado y lo aplicamos
            CString csRatio;
            csRatio.Format("%.2f",theApp.m_configuracion.m_ratio_inicial);
            m_ratio.SetWindowText(csRatio);
            
            MostrarFiltro(theApp.Rueda.GetFilter()); //Actualizamos el filtro actual
            ActualizarEscala(); //en dialogo usando theApp.m_CorreccionGeometrica.m_dEscalaObjetivo

            // El display tiene que ajustarse al tamaño de imagen y el zoom actual
            long anchoImagen = (long)floor(theApp.m_ParamIni.Cam.anchoImagen * theApp.m_configuracion.m_ratio_inicial  + 0.5);
            long altoImagen = (long)floor(theApp.m_ParamIni.Cam.altoImagen * theApp.m_configuracion.m_ratio_inicial + 0.5);
            //Ajustamos la ventana principal tambien
            m_imagen.SetWindowPos(NULL,0,0,anchoImagen,altoImagen, SWP_NOMOVE | SWP_NOZORDER); //primero imagen para que OnSize funciones correctamente
            //Ajustamos la ventana principal tambien
            SetWindowPos(NULL,0,0,anchoImagen+m_anchoResto,altoImagen+m_altoResto, SWP_NOMOVE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOACTIVATE);
        }
        else
        {
            MdispDeselect(M_display_normal,M_imagen1);
        }

    }
}
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);
}
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);
}
// 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;
}
// 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;

}
// Se elimina la imagen correspondiente al filtro "numFiltro", liberando la memoria del buffer
// Se muestra la imagen correspondiente al primer filtro anterior o posterior disponible
// Devuelve el nuevo filtro que se muestra o -1 si no hay mas
int ControlImagenes::EliminarImagen(int numFiltro, CStatic&	m_control)
{
    int filtroAnterior = EncontrarFiltroAnterior(numFiltro);

    if (filtroAnterior == -1)
    {
        // No hay ningun filtro
        MdispDeselect(m_Mildisplay,m_Milimagen[numFiltro-1]);
        m_control.SetBitmap((HBITMAP)m_backgound_bitmap); 

        //al quitar el fondo, se queda lo ultimo (es decir m_backgound_bitmap)
        //y ademas se veran las imagenes MIL cuando haya
        m_control.SetBitmap(NULL); 
    }
    else
    {
        MdispSelectWindow(m_Mildisplay,m_Milimagen[filtroAnterior-1],m_control);
    }
    MbufFree(m_Milimagen[numFiltro-1]);
    m_Milimagen[numFiltro-1] = M_NULL;
    m_numImagenes--; 

    return filtroAnterior;
}
// 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;
}
Пример #8
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
   /////////////////////////////////////////////////////////////////////////
   }