예제 #1
0
bool CKmlDlg::WriteToFile2(U08 type)
{	
	static U16 last_hh = 0;
	static U16 last_mm = 0;
	static F32 last_ss = -1;

	if(ut == Unknown)
	{
		if(IsFixed(msg_gpgga.GPSQualityIndicator))
			ut = UsingGGA;
		if(IsFixed(msg_gprmc.Status))
			ut = UsingRMC;
	}

	//if(ut == UsingGGA && last_hh == msg_gpgga.Hour && last_mm == msg_gpgga.Min && last_ss == msg_gpgga.Sec)
	//{
	//	return false;
	//}
	//if(ut == UsingRMC && last_hh == msg_gprmc.Hour && last_mm == msg_gprmc.Min && last_ss == msg_gprmc.Sec)
	//{
	//	return false;
	//}

	if((type == MSG_GGA || type == MSG_GNS) && IsFixed(msg_gpgga.GPSQualityIndicator))
	{
    CString timeStr;
		timeStr.Format("%02d:%02d:%05.2f", msg_gpgga.Hour, msg_gpgga.Min, msg_gpgga.Sec);
		kml.PushOnePoint2(GetLon(msg_gpgga.Longitude, msg_gpgga.Longitude_E_W), 
			GetLat(msg_gpgga.Latitude, msg_gpgga.Latitude_N_S), 
      msg_gpgga.Altitude, 
      NULL,
      NULL,
      timeStr, 
      GetGnssQualityMode(msg_gpgga.GPSQualityIndicator, (U08)msg_gpgsa.Mode, (U08)msg_glgsa.Mode, (U08)msg_gagsa.Mode, (U08)msg_bdgsa.Mode, (U08)msg_gigsa.Mode));
		last_hh = msg_gpgga.Hour;
		last_mm = msg_gpgga.Min;
		last_ss = msg_gpgga.Sec;
		return true;
	}
	else if (type == MSG_RMC && msg_gprmc.Status == 'A')
	{
		CString timeStr;
		timeStr.Format("%02d:%02d:%05.2f", msg_gprmc.Hour, msg_gprmc.Min, msg_gprmc.Sec);
		kml.PushOnePoint2(GetLon(msg_gprmc.Longitude, msg_gprmc.Longitude_E_W), 
			GetLat(msg_gprmc.Latitude, msg_gprmc.Latitude_N_S), 
      msg_gpgga.Altitude, 
      &msg_gprmc.SpeedKnots,
      &msg_gprmc.TrueCourse,
      timeStr,
      GetGnssQualityMode(msg_gprmc.ModeIndicator));
		last_hh = msg_gprmc.Hour;
		last_mm = msg_gprmc.Min;
		last_ss = msg_gprmc.Sec;
		return true;
	}
	return false;
}
예제 #2
0
void mitk::LevelWindow::SetRangeMinMax(mitk::ScalarType min, mitk::ScalarType max)
{
  if ( IsFixed() ) return;
  m_RangeMin = min;
  m_RangeMax = max;
  EnsureConsistency();
}
예제 #3
0
void mitk::LevelWindow::SetWindowBounds(mitk::ScalarType lowerBound, mitk::ScalarType upperBound, bool expandRangesIfNecessary)
{
  if ( IsFixed() ) return;

  m_LowerWindowBound = lowerBound;
  m_UpperWindowBound = upperBound;

  if (expandRangesIfNecessary)
  {
    /* if caller is sure he wants exactly that level/window, we make sure the limits match */
    if (m_LowerWindowBound > m_UpperWindowBound)
      std::swap(m_LowerWindowBound, m_UpperWindowBound);
    if ( m_LowerWindowBound < m_RangeMin )
    {
      m_RangeMin = m_LowerWindowBound;
    }

    if ( m_UpperWindowBound > m_RangeMax )
    {
      m_RangeMax = m_UpperWindowBound;
    }
  }

  EnsureConsistency();
}
예제 #4
0
static  void    IUnBytes( char HPGM *dst, unsigned long len ) {
//=============================================================

    uint        amt;
    ftnfile     *fcb;
    char        *src;

    fcb = IOCB->fileinfo;
    if( IsFixed() && ( fcb->col + len > fcb->len ) ) {
        IOErr( IO_UNFMT_RECL );
    }
    src = fcb->buffer + fcb->col;
    for(;;) {
        amt = fcb->len - fcb->col;
        if( amt > len ) {
            amt = len;
        }
        pgm_memput( dst, src, amt );
        fcb->col += amt;
        len -= amt;
        if( len == 0 ) break;
        dst += amt;
        src = fcb->buffer;
        NextUnFmtRec();
    }
}
예제 #5
0
void    SendEOR( void ) {
//=================

    ftnfile     *fcb;
    int         len;
    bool        ifile;

    fcb = IOCB->fileinfo;
    ifile = fcb->internal != NULL;
    if( ifile ) {
        if( fcb->flags & FTN_EOF ) {
            IOErr( IO_IFULL );
        }
        if( fcb->recnum >= IOCB->elmts ) {
            fcb->flags |= FTN_EOF;
            SendIFBuff( fcb->buffer, fcb->bufflen, fcb->recnum, fcb->internal );
        } else {
            SendIFBuff( fcb->buffer, fcb->bufflen, fcb->recnum, fcb->internal );
            memset( fcb->buffer, ' ', fcb->bufflen );
        }
    } else {
        if( IsFixed() ) {
            fcb->col = fcb->bufflen;
        }
        if( fcb->fileptr != NULL ) {
            FPutBuff( fcb );
            ChkIOErr( fcb );
        }
    }
    // Write to the listing file after we've written to DB_STD_OUTPUT so
    // that if we get an error writing to the listing file, the buffer for
    // DB_STD_OUTPUT will be empty (i.e. when we report the error writing
    // to the listing file we will need to use DB_STD_OUTPUT's buffer).
    // Note that we have to set fcb->col to 0 so that the error message
    // will go at the beginning of the buffer.
    len = fcb->col;
    fcb->col = 0;
    if( ( IOCB->flags & IOF_NOCR ) == 0 ) {
        UpdateRecNum( fcb );
        // eofrecnum used to be updated in ExWrite().
        // We MUST set eofrecnum here in case we abort the WRITE and
        // suicide which will NOT return to ExWrite().
        // If we don't do this here, the next time a WRITE is executed
        // on this unit, we get IO_PAST_EOF error.
        if( !ifile && !NoEOF( fcb ) ) {
            if( fcb->accmode <= ACCM_SEQUENTIAL ) {
                fcb->eofrecnum = fcb->recnum;
            }
        }
        if( !ifile ) {
            memset( fcb->buffer, ' ', fcb->bufflen );
        }
    }
    IOCB->flags &= ~IOF_NOCR;
}
예제 #6
0
void PointsCurveValue::SetForFlags(bool parIsActive)
{
  if (IsOpt() && (!control.IsOptimization()))
    pType = pcvFixed;

  if (IsVary() && control.IsSampleSim())
    pType = pcvFixed;

  if (IsFixed() && control.IsOptimization() && pOptData && pOptData->wasActive)
    pType = pcvOpt;

  SetActive(parIsActive);
}
예제 #7
0
void mitk::LevelWindow::SetToImageRange(const mitk::Image *image)
{
    if ( IsFixed() )
        return;

    if ( image == NULL || !image->IsInitialized() ) return;

    ScalarType minValue = image->GetStatistics()->GetScalarValueMin(0);
    ScalarType maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute(0);
    SetRangeMinMax(minValue, maxValue);
    SetDefaultBoundaries(minValue, maxValue);
    SetWindowBounds(minValue, maxValue);
    SetDefaultLevelWindow((maxValue - minValue) / 2 + minValue, maxValue - minValue);
}
예제 #8
0
void mitk::LevelWindow::SetDefaultBoundaries(mitk::ScalarType low, mitk::ScalarType up)
{
  if ( IsFixed() )  return;
  m_DefaultLowerBound = low;
  m_DefaultUpperBound = up;
  // Check if default window is ok
  { 
    if ( m_DefaultLowerBound > m_DefaultUpperBound )   
      std::swap(m_DefaultLowerBound,m_DefaultUpperBound);

    if (m_DefaultLowerBound == m_DefaultUpperBound )  
        m_DefaultLowerBound--;
  }
  EnsureConsistency();
}
예제 #9
0
BOOL ShellCache::IsPathAllowed(LPCTSTR path)
{
	ValidatePathFilter();
	Locker lock(m_critSec);
	tristate_t allowed = pathFilter.IsPathAllowed(path);
	if (allowed != tristate_unknown)
		return allowed == tristate_true ? TRUE : FALSE;

	UINT drivetype = 0;
	int drivenumber = PathGetDriveNumber(path);
	if ((drivenumber >= 0) && (drivenumber < 25))
	{
		drivetype = drivetypecache[drivenumber];
		if ((drivetype == -1) || ((GetTickCount64() - drivetypeticker) > DRIVETYPETIMEOUT))
		{
			if ((DWORD(drivefloppy) == 0) && ((drivenumber == 0) || (drivenumber == 1)))
				drivetypecache[drivenumber] = DRIVE_REMOVABLE;
			else
			{
				drivetypeticker = GetTickCount64();
				TCHAR pathbuf[MAX_PATH + 4] = { 0 };		// MAX_PATH ok here. PathStripToRoot works with partial paths too.
				wcsncpy_s(pathbuf, path, _countof(pathbuf) - 1);
				PathStripToRoot(pathbuf);
				PathAddBackslash(pathbuf);
				CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": GetDriveType for %s, Drive %d\n", pathbuf, drivenumber);
				drivetype = GetDriveType(pathbuf);
				drivetypecache[drivenumber] = drivetype;
			}
		}
	}
	else
	{
		TCHAR pathbuf[MAX_PATH + 4] = { 0 };		// MAX_PATH ok here. PathIsUNCServer works with partial paths too.
		wcsncpy_s(pathbuf, path, _countof(pathbuf) - 1);
		if (PathIsUNCServer(pathbuf))
			drivetype = DRIVE_REMOTE;
		else
		{
			PathStripToRoot(pathbuf);
			PathAddBackslash(pathbuf);
			if (wcsncmp(pathbuf, drivetypepathcache, MAX_PATH - 1) == 0) // MAX_PATH ok.
				drivetype = drivetypecache[26];
			else
			{
				CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L"GetDriveType for %s\n", pathbuf);
				drivetype = GetDriveType(pathbuf);
				drivetypecache[26] = drivetype;
				wcsncpy_s(drivetypepathcache, pathbuf, MAX_PATH - 1); // MAX_PATH ok.
			}
		}
	}
	if ((drivetype == DRIVE_REMOVABLE) && (!IsRemovable()))
		return FALSE;
	if ((drivetype == DRIVE_FIXED) && (!IsFixed()))
		return FALSE;
	if (((drivetype == DRIVE_REMOTE) || (drivetype == DRIVE_NO_ROOT_DIR)) && (!IsRemote()))
		return FALSE;
	if ((drivetype == DRIVE_CDROM) && (!IsCDRom()))
		return FALSE;
	if ((drivetype == DRIVE_RAMDISK) && (!IsRAM()))
		return FALSE;
	if ((drivetype == DRIVE_UNKNOWN) && (IsUnknown()))
		return FALSE;

	return TRUE;
}
예제 #10
0
/*!
This method initializes a mitk::LevelWindow from an mitk::Image. The algorithm is as follows:

Default to taking the central image slice for quick analysis.

Compute the smallest (minValue), second smallest (min2ndValue), second largest (max2ndValue), and
largest (maxValue) data value by traversing the pixel values only once. In the
same scan it also computes the count of minValue values and maxValue values.
After that a basic histogram with specific information about the
extrems is complete.

If minValue == maxValue, the center slice is uniform and the above scan is repeated for
the complete image, not just one slice

Next, special cases of images with only 1, 2 or 3 distinct data values
have hand assigned level window ranges.

Next the level window is set relative to the inner range IR = lengthOf([min2ndValue, max2ndValue])

For count(minValue) > 20% the smallest values are frequent and should be
distinct from the min2ndValue and larger values (minValue may be std:min, may signify
something special) hence the lower end of the level window is set to min2ndValue - 0.5 * IR
 
For count(minValue) <= 20% the smallest values are not so important and can
blend with the next ones => min(level window) = min2ndValue

And analog for max(level window):
count(max2ndValue) > 20%:  max(level window) = max2ndValue + 0.5 * IR
count(max2ndValue) < 20%:  max(level window) = max2ndValue

In both 20%+ cases the level window bounds are clamped to the [minValue, maxValue] range

In consequence the level window maximizes contrast with minimal amount of
computation and does do useful things if the data contains std::min or
std:max values or has only 1 or 2 or 3 data values.
*/
void mitk::LevelWindow::SetAuto(const mitk::Image* image, bool /*tryPicTags*/, bool guessByCentralSlice)
{
  if ( IsFixed() )
    return;
  
  if ( image == NULL || !image->IsInitialized() ) return;

  const mitk::Image* wholeImage = image;
  ScalarType minValue = 0.0;
  ScalarType maxValue = 0.0;
  ScalarType min2ndValue = 0.0; 
  ScalarType max2ndValue = 0.0;
  mitk::ImageSliceSelector::Pointer sliceSelector = mitk::ImageSliceSelector::New();
  if ( guessByCentralSlice )
  {
    sliceSelector->SetInput(image);
    sliceSelector->SetSliceNr(image->GetDimension(2)/2);
    sliceSelector->SetTimeNr(image->GetDimension(3)/2);
    sliceSelector->SetChannelNr(image->GetDimension(4)/2);
    sliceSelector->Update();
    image = sliceSelector->GetOutput();
    if ( image == NULL || !image->IsInitialized() ) return;

    minValue    = image->GetStatistics()->GetScalarValueMin();
    maxValue    = image->GetStatistics()->GetScalarValueMaxNoRecompute();
    min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute();
    max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute();
    if ( minValue == maxValue )
    {
      // guessByCentralSlice seems to have failed, lets look at all data
      image       = wholeImage;
      minValue    = image->GetStatistics()->GetScalarValueMin();
      maxValue    = image->GetStatistics()->GetScalarValueMaxNoRecompute();
      min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute();
      max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute();
    }
  }
  else
  {
    const_cast<Image*>(image)->Update();
    minValue    = image->GetStatistics()->GetScalarValueMin(0);
    maxValue    = image->GetStatistics()->GetScalarValueMaxNoRecompute(0);
    min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(0);
    max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(0);
    for (unsigned int i = 1; i < image->GetDimension(3); ++i)
    {
      ScalarType minValueTemp = image->GetStatistics()->GetScalarValueMin(i);
      if (minValue > minValueTemp)
        minValue    = minValueTemp;
      ScalarType maxValueTemp = image->GetStatistics()->GetScalarValueMaxNoRecompute(i);
      if (maxValue < maxValueTemp)
        maxValue = maxValueTemp;
      ScalarType min2ndValueTemp = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(i);
      if (min2ndValue > min2ndValueTemp)
        min2ndValue = min2ndValueTemp; 
      ScalarType max2ndValueTemp = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(i);
      if (max2ndValue > max2ndValueTemp)
        max2ndValue = max2ndValueTemp; 
    }
  }

  // Fix for bug# 344 Level Window wird bei Eris Cut bildern nicht richtig gesetzt
  if (   image->GetPixelType().GetPixelTypeId()==itk::ImageIOBase::SCALAR
      && image->GetPixelType().GetTypeId() == typeid(int)
      && image->GetPixelType().GetBpe() >= 8)
  {
    // the windows compiler complains about ambiguos 'pow' call, therefore static casting to (double, int)
    if (minValue == -( pow( (double) 2.0, static_cast<int>(image->GetPixelType().GetBpe()/2) ) ) )
    {
      minValue = min2ndValue;
    }
  }
  // End fix

  //// uniform image
  if ( minValue == maxValue )
  {
    minValue = maxValue-1;
  }
  else
  {
      //Due to bug #8690 level window now is no longer of fixed range by default but the range adapts according to levelwindow interaction
      //This is done because the range should be a little bit larger from the beginning so that the scale doesn't start to resize right from the beginning
      double additionalRange = 0.15*(maxValue-minValue);
      minValue -= additionalRange;
      maxValue += additionalRange;
  }
  SetRangeMinMax(minValue, maxValue);
  SetDefaultBoundaries(minValue, maxValue);
/*
  if ( tryPicTags ) // level and window will be set by informations provided directly by the mitkIpPicDescriptor
  {
    if ( SetAutoByPicTags(const_cast<Image*>(image)->GetPic()) )
    {
      return;
    }
  }
 */
   
  unsigned int numPixelsInDataset = image->GetDimensions()[0];
  for ( unsigned int k=0;  k<image->GetDimension();  ++k ) numPixelsInDataset *= image->GetDimensions()[k];
  unsigned int minCount = image->GetStatistics()->GetCountOfMinValuedVoxelsNoRecompute();
  unsigned int maxCount = image->GetStatistics()->GetCountOfMaxValuedVoxelsNoRecompute();
  float minCountFraction = minCount/float(numPixelsInDataset);
  float maxCountFraction = maxCount/float(numPixelsInDataset);

  //// binary image
  if ( min2ndValue == maxValue )
  {
    // noop; full range is fine
  }

  //// triple value image, put middle value in center of gray level ramp
  else if ( min2ndValue == max2ndValue )
  {
    ScalarType minDelta = std::min(min2ndValue-minValue, maxValue-min2ndValue);
    minValue = min2ndValue - minDelta;
    maxValue = min2ndValue + minDelta;
  }

  // now we can assume more than three distict scalar values
  else
  {
    ScalarType innerRange = max2ndValue - min2ndValue;
    
    if ( minCountFraction > 0.2 )  //// lots of min values -> make different from rest, but not miles away
    {
      ScalarType halfInnerRangeGapMinValue = min2ndValue - innerRange/2.0;
      minValue = std::max(minValue, halfInnerRangeGapMinValue);
    }
    else  //// few min values -> focus on innerRange
    {
      minValue = min2ndValue;
    }

    if ( maxCountFraction > 0.2 )  //// lots of max values -> make different from rest
    {
      ScalarType halfInnerRangeGapMaxValue = max2ndValue + innerRange/2.0;
      maxValue = std::min(maxValue, halfInnerRangeGapMaxValue);
    }
    else  //// few max values -> focus on innerRange
    {
      maxValue = max2ndValue;
    }
  }
  SetWindowBounds(minValue, maxValue);
  SetDefaultLevelWindow((maxValue - minValue) / 2 + minValue, maxValue - minValue);
}