Пример #1
0
void LstOdaSrvDetails::InsertLine(const wxString &Name, const wxString &Value)
{
    wxListItem ListItem;
    
    ListItem.SetMask(wxLIST_MASK_TEXT);
    
    // Name Column
    ListItem.SetText(Name);
    ListItem.SetColumn(srvdetails_field_name);
    ListItem.SetId(InsertItem(GetItemCount(), ListItem.GetText()));
    
    if (BGItemAlternator == *wxWHITE)
    {
        BGItemAlternator.Set(wxUint8(245), wxUint8(245), wxUint8(245));
    }
    else
        BGItemAlternator = *wxWHITE;
    
    ListItem.SetBackgroundColour(BGItemAlternator);
    
    SetItem(ListItem);
    
    // Value Column
    ListItem.SetText(Value);    
    ListItem.SetColumn(srvdetails_field_value);
    SetItem(ListItem);
}
Пример #2
0
void wxAdvancedListCtrl::OnCreateControl(wxWindowCreateEvent &event)
{
    SortOrder = 0; 
    SortCol = 0; 

    ItemShade.Set(wxUint8(245), wxUint8(245), wxUint8(245));

    // Set up the image list.
    AddImageSmall(NULL);
}
Пример #3
0
// converts the image to a plain 3*8bit mono but RGB sized bitmap with applied gamma
bool wxArtSample::ConvertToBMP(float p_gamma, long p_minIn, long p_maxIn)
{
   long min, max;
	double minIn, maxIn, minOut, maxOut, gammaOut;
   double b,m, vv;

   if ( !m_pImageMem ) return false;// ERROR EXIT no image

   min = 0;
   max = 65535;

   // get the in range and gamma arguments
   minIn = double( (p_minIn>=0)? p_minIn:min );
   maxIn = double( (p_maxIn>=0)? p_maxIn:max );

   maxOut = 254.5;   minOut  = 0.0; // defines the output pixel value range (full 8bit) (prevent fp rounding issue)
   gammaOut = (p_gamma<0.1) ? 0.1 : ( (p_gamma>9.99) ? 9.99 : p_gamma); // clip arg range

   // basic equation is Out = m * In + b
   //  where Out is in the range of USHORT (0..2^16-1)
   //  and In is an arbitrary range based on the Input datatype

   // solved Eq is:
   // m = (maxOut - minOut) / (maxIn-minIn)
   // b = minOut - m*minIn
   m = (maxOut - minOut) / (maxIn - minIn);
   b = minOut - m * minIn;

   // define some helpers here
   size_t sw = m_subRect.GetWidth();      // dst coords
   size_t sh = m_subRect.GetHeight();     // dst coords

   // prepare BMP datastore
   wxUint16 scanwidth = sw*3;
   //scanwidth = (scanwidth +3) & ~3; // DWORD align if needed (?? dont know for wxImage)
   if (m_pImageBMP) delete m_pImageBMP;
   m_pImageBMP = new ByteImageMem(sh*scanwidth); // allocate and RGB map (for wxImage - must be malloc!!)
   if (!m_pImageBMP->MemOK()) return false; // ERROR EXIT no memory

   const wxUint16* inPtr = m_pImageMem->WordMemPtr();
   wxUint8* outPtr;
   wxUint8  outVal;
   for (size_t y=0; y<sh; y++) {
      outPtr = m_pImageBMP->ByteMemPtrRef() + y*scanwidth;
      for (size_t x=0; x<sw; x++) {
         vv = (double)*inPtr++;
         // clip input
         vv = (vv<minIn) ? minIn : ((vv>maxIn) ? maxIn : vv);
         // scale with out = m * In + b; then apply gamma based on Out range
         //vv = m * vv + b; // plain linear conversion
         vv = maxOut *  pow( ((m * vv + b) / maxOut), 1.0/gammaOut);
         // clip calculated pixel at out range
         outVal = wxUint8( (vv<minOut) ? minOut : ((vv>maxOut) ? maxOut : vv) );
         *outPtr++ = outVal; *outPtr++ = outVal; *outPtr++ = outVal; // set into RGB
      }//cols
   }//rows
   // now we have an RBG map that suits the wxImage data ptr
   return true;
}
Пример #4
0
static CharsetItem* BuildReverseTable(const wxUint16 *tbl)
{
    CharsetItem *rev = new CharsetItem[128];

    for (int i = 0; i < 128; i++)
        rev[i].c = wxUint8(128 + i), rev[i].u = tbl[i];

    qsort(rev, 128, sizeof(CharsetItem), CompareCharsetItems);

    return rev;
}
Пример #5
0
/////////////////////////////////////////////////////////////////////////////
//
// Returns the Byte at port portAddress
//
PortW32::PortAccessStatus PortW32::get_port(wxUint8& inByte)
{
   if (Released()) return IPAC_PortReleased;

	if ( IsPortParallel() ) {
      m_lastError = IPAC_Success;
      if (m_PortTalk_Handle == INVALID_HANDLE_VALUE) {
         m_lastError = IPAC_NoInterface;
         return m_lastError; // ERROR EXIT
      }
      if (m_portAddress == 0) {
         m_lastError = IPAC_NoInterface;
         return m_lastError; // ERROR EXIT
      }

      if (m_ProtectedOS) {
         BOOL        success;
         USHORT      myPort = (USHORT)m_portAddress;
         BYTE        myByte = 0;
         DWORD       bytesReturned;

         success = DeviceIoControl(m_PortTalk_Handle,
                           (DWORD)IOCTL_READ_PORT_UCHAR,
                           &myPort, sizeof(myPort),                  /*in data*/
                           &myByte, sizeof(myByte), &bytesReturned,  /*out data*/
                           NULL);

         if (!success)
            //printf("Error occured during inportb while talking to PortTalk driver %d\n",GetLastError());
            m_lastError = IPAC_GetFailed;
         else
            inByte = myByte;
      }

      else {
         // raw port access
         USHORT myPort = (USHORT)m_portAddress;
         BYTE   myByte = 0;
         __asm
         {
            mov dx, myPort
            in  al, dx
            mov myByte, al
         }
         inByte = myByte;
      }
   }

   else if (IsPortGPUSB()) {
      m_lastError = IPAC_Success;
      if (m_pGpUsb == NULL) {
         m_lastError = IPAC_NoInterface;
         return m_lastError; // ERROR EXIT
      }
      unsigned short val;
      m_pGpUsb->GetValue(val);
      inByte = wxUint8(val & 0xff);
   }

   else if (IsPortLXUSB()) {
      m_lastError = IPAC_Success;
      if (m_pLxUsb == NULL) {
         m_lastError = IPAC_NoInterface;
         return m_lastError; // ERROR EXIT
      }
      unsigned short val;
      m_pLxUsb->GetValue(val);
      inByte = wxUint8(val & 0xff);
   }

   else {
      // other ports
      m_lastError = IPAC_NotSupported;
   }

	return m_lastError;

}//END Get
Пример #6
0
/////////////////////////////////////////////////////////////////////////////
//
// Returns the outgoing Byte at port portAddress
PortUX::PortAccessStatus PortUX::get_port(wxUint8 &inByte)
{
   inByte=0; // default

   if (Released()) return IPAC_PortReleased;

	if ( IsPortParallel() ) {

      m_lastError = IPAC_Success;
      if (m_ParallelPort_Handle <0) {
         m_lastError = IPAC_NoInterface;
         return m_lastError;
      }

       int iocMode;
       wxUint8 cIn;

       iocMode = 0; // null = Forward Direction registers
       if ( xioctl(m_ParallelPort_Handle, PPDATADIR, &iocMode) <0 ) {
         m_lastError = IPAC_GetFailed;
       }
       else {
           if ( xioctl(m_ParallelPort_Handle, PPRDATA, &cIn) <0) {
               m_lastError = IPAC_GetFailed;
           }
           else {
               inByte = cIn;
           }
      }
   }

   else if (IsPortGPUSB()) {
      m_lastError = IPAC_Success;
      if (m_pGpUsb == NULL) {
         m_lastError = IPAC_NoInterface;
         return m_lastError; // ERROR EXIT
      }
      unsigned short val;
      m_pGpUsb->GetValue(val);
      inByte = wxUint8(val & 0xff);
   }

   else if (IsPortLXUSB()) {
      m_lastError = IPAC_Success;
      if (m_pLxUsb == NULL) {
         m_lastError = IPAC_NoInterface;
         return m_lastError; // ERROR EXIT
      }
      unsigned short val;
      m_pLxUsb->GetValue(val);
      inByte = wxUint8(val & 0xff);
   }

   else {
      // other ports
      m_lastError = IPAC_NotSupported;
   }

	return m_lastError;

}
Пример #7
0
bool wxLongExpoPort::RestoreFromConfigLongExpo(wxConfig* config)
{
   wxString OldPath = config->GetPath();
   config->SetPath(wxT("LongExposure"));

   wxString portname;
   wxPortManager* pm = wxF()->portManager();
   // either we find a portname in config or have to try the first in the list
   if(config->Read(_T("LXCamPort"),&portname, wxT("~"))) {
      wxPortDescr pd = pm->PortDescriptorFirst(); // get first (should be "!None!")
      if ( 0 == portname.CmpNoCase(wxT("~")) || 0==portname.CmpNoCase(wxT(""))  ) {
         // ~ or empty string means no config value found
         // an empty string can appear in the config, so we have to test for it
         wxMessageBox(_T("Auto-selected long exposure control port ") + pd.PortName() + _T(", please check port settings."));
      }
      else {
         // there was a port already used, so use its descriptor
         pd = pm->PortDescriptor(portname);
      }

      // Let LE use this port
      if ( UseLEPort(pd) ) {
         // OK - setup the bits and flags from config (or use defaults if not configured yet)
         long value=this->LXmask();
         if(config->Read(_T("LXmask"),&value)) this->SetLXmask(wxUint8(value));

         value=this->LXinit();
         if(config->Read(_T("LXinit"),&value)) this->SetLXinit(wxUint8(value));

         value=this->LXreadout();
         if(config->Read(_T("LXreadout"),&value)) this->SetLXreadout(wxUint8(value));

         value=this->LXampOn();
         if(config->Read(_T("LXampOn"),&value)) this->SetLXampOn(wxUint8(value));

         value=this->LXshutOn();
         if(config->Read(_T("LXshutOn"),&value)) this->SetLXshutOn(wxUint8(value));

         value=this->InvertedLogic();
         if(config->Read(_T("LXinvertedLogic"),&value)) this->SetInvertedLogic((value!=0)?true:false);

         value=this->InvertedLogic();
         if(config->Read(_T("LXuseAmp"),&value)) this->SetAMPmodeOn((value!=0)?true:false);

         value=this->InvertedLogic();
         if(config->Read(_T("LXuseShutter"),&value)) this->SetCycleShutter((value!=0)?true:false);

         // finished setting up the bits..
         if ( ! this->CommitConfiguration() ) {
            wxMessageBox(_T("Cannot configure long exposure control port ") + pd.PortName() \
                                       + _T(", please check port settings."));
         }
         this->LXmodeOff();  // init to make port lines defined

      }
      else {
         wxMessageBox(_T("Cannot use port ") + pd.PortName() + _T(" for long exposure, please check port settings."));
         return false;
      }
   }
   else {
      // create the default setting
      config->SetPath(OldPath);
      SaveToConfigLongExpo(config);
   }

   config->SetPath(OldPath);

   return true;
}
Пример #8
0
bool CWAVFileWriter::write(const wxFloat32* buffer, unsigned int length)
{
	wxASSERT(m_file != NULL);
	wxASSERT(buffer != NULL);
	wxASSERT(length > 0U && length <= m_blockSize);

	unsigned int bytes = 0U;
	unsigned int i;
	size_t n = 0UL;

	switch (m_sampleWidth) {
		case 8U:
			switch (m_channels) {
				case 1U:
					for (i = 0U; i < length; i++)
						m_buffer8[i] = wxUint8(buffer[i] * 128.0F + 127.0F);
					break;
				case 2U:
					for (i = 0U; i < (length * 2U); i++)
						m_buffer8[i] = wxUint8(buffer[i] * 128.0F + 127.0F);
					break;
			}

			bytes = length * m_channels * sizeof(wxUint8);

			n = m_file->Write(m_buffer8, bytes);

			break;

		case 16U:
			switch (m_channels) {
				case 1U:
					for (i = 0U; i < length; i++)
						m_buffer16[i] = wxInt16(buffer[i] * 32768.0F);
					break;
				case 2U:
					for (i = 0U; i < (length * 2U); i++)
						m_buffer16[i] = wxInt16(buffer[i] * 32768.0F);
					break;
			}

			bytes = length * m_channels * sizeof(wxInt16);

			n = m_file->Write(m_buffer16, bytes);

			break;

		case 32U:
			switch (m_channels) {
				case 1U:
					for (i = 0U; i < length; i++)
						m_buffer32[i] = wxFloat32(buffer[i]);
					break;
				case 2U:
					// Swap I and Q
					for (i = 0U; i < length; i++) {
						m_buffer32[i * 2U + 0U] = wxFloat32(buffer[i * 2U + 1U]);
						m_buffer32[i * 2U + 1U] = wxFloat32(buffer[i * 2U + 0U]);
					}
					break;
			}

			bytes = length * m_channels * sizeof(wxFloat32);

			n = m_file->Write(m_buffer32, bytes);

			break;
	}

	m_length += n;

	return n == bytes;
}
Пример #9
0
bool CWAVFileWriter::write(const float* buffer, unsigned int length)
{
	wxASSERT(m_handle != NULL);
	wxASSERT(buffer != NULL);
	wxASSERT(length > 0U);

	unsigned int i;
	LONG bytes = 0L;
	LONG n = 0L;

	switch (m_sampleWidth) {
		case 8U:
			switch (m_channels) {
				case 1U:
					for (i = 0U; i < length; i++)
						m_buffer8[i] = wxUint8(buffer[i] * 128.0F + 127.0F);
					break;
				case 2U:
					for (i = 0U; i < (length * 2U); i++)
						m_buffer8[i] = wxUint8(buffer[i] * 128.0F + 127.0F);
					break;
			}

			bytes = length * m_channels * sizeof(wxUint8);

			n = ::mmioWrite(m_handle, (char *)m_buffer8, bytes);

			break;

		case 16U:
			switch (m_channels) {
				case 1U:
					for (i = 0U; i < length; i++)
						m_buffer16[i] = wxInt16(buffer[i] * 32768.0F);
					break;
				case 2U:
					for (i = 0U; i < (length * 2U); i++)
						m_buffer16[i] = wxInt16(buffer[i] * 32768.0F);
					break;
			}

			bytes = length * m_channels * sizeof(wxInt16);

			n = ::mmioWrite(m_handle, (char *)m_buffer16, bytes);

			break;

		case 32U:
			switch (m_channels) {
				case 1U:
					for (i = 0U; i < length; i++)
						m_buffer32[i] = wxFloat32(buffer[i]);
					break;
				case 2U:
					// Swap I and Q
					for (i = 0U; i < length; i++) {
						m_buffer32[i * 2U + 0U] = wxFloat32(buffer[i * 2U + 1U]);
						m_buffer32[i * 2U + 1U] = wxFloat32(buffer[i * 2U + 0U]);
					}
					break;
			}

			bytes = length * m_channels * sizeof(wxFloat32);

			n = ::mmioWrite(m_handle, (char *)m_buffer32, bytes);

			break;
	}

	return n == bytes;
}