예제 #1
0
String ProcessInstance::ToSource( const IsoString& language, const IsoString& varId, int indent ) const
{
   char16_type* s = (*API->Process->GetProcessInstanceSourceCode)(
                              ModuleHandle(), handle, language.c_str(), varId.c_str(), indent );
   if ( s == 0 )
      throw APIFunctionError( "GetProcessInstanceSourceCode" );
   String source( s );
   Module->Deallocate( s );
   return source;
}
예제 #2
0
 void SwitchProperty::addElement(IsoString elementName, IsoString value){
 	 ISwitch* sp = ((ISwitchVectorProperty*) m_property->getProperty())->sp;
 	 int nsp = ((ISwitchVectorProperty*) m_property->getProperty())->nsp;
 	 sp = (ISwitch*) realloc(sp, (nsp+1) * sizeof(ISwitch));
 	 CHECK_POINTER(sp);
 	 strcpy(sp->name, elementName.c_str());
 	 sp->s = (strcmp(value.c_str(),"ON")==0) ? ISS_ON : ISS_OFF ;
 	 sp->svp =(ISwitchVectorProperty*) m_property->getProperty();
 	 ((ISwitchVectorProperty*) m_property->getProperty())->nsp++;
 	 ((ISwitchVectorProperty*) m_property->getProperty())->sp = sp;
  }
예제 #3
0
void TextProperty::addElement(IsoString elementName, IsoString value) {
	IText* tp = ((ITextVectorProperty*) m_property->getProperty())->tp;
	int ntp = ((ITextVectorProperty*) m_property->getProperty())->ntp;
	tp = (IText*) realloc(tp, (ntp + 1) * sizeof(IText));
	CHECK_POINTER(tp);
	strcpy(tp->name, elementName.c_str());
	//FIXME Leaks memory?
	tp->text = (char*) malloc(sizeof(value.c_str()));
	strcpy(tp->text, value.c_str());
	tp->tvp = (ITextVectorProperty*) m_property->getProperty();
	((ITextVectorProperty*) m_property->getProperty())->ntp++;
	((ITextVectorProperty*) m_property->getProperty())->tp = tp;
 }
예제 #4
0
파일: View.cpp 프로젝트: SunGong1993/PCL
ViewPropertyAttributes View::PropertyAttributes( const IsoString& property ) const
{
   uint32 flags = 0;
   if ( (*API->View->GetViewPropertyAttributes)( ModuleHandle(), handle, property.c_str(), &flags, 0/*type*/ ) == api_false )
      throw APIFunctionError( "GetViewPropertyAttributes" );
   return ViewPropertyAttributes( ViewPropertyAttribute::mask_type( flags ) );
}
예제 #5
0
파일: View.cpp 프로젝트: SunGong1993/PCL
Variant::data_type View::PropertyType( const IsoString& property ) const
{
   uint64 type = 0;
   if ( (*API->View->GetViewPropertyAttributes)( ModuleHandle(), handle, property.c_str(), 0/*flags*/, &type ) == api_false )
      throw APIFunctionError( "GetViewPropertyAttributes" );
   return VariantTypeFromAPIPropertyType( type );
}
예제 #6
0
파일: View.cpp 프로젝트: SunGong1993/PCL
void View::SetPropertyValue( const IsoString& property, const Variant& value, bool notify, ViewPropertyAttributes attributes )
{
   api_property_value apiValue;
   APIPropertyValueFromVariant( apiValue, value );
   if ( (*API->View->SetViewPropertyValue)( ModuleHandle(), handle, property.c_str(), &apiValue, attributes, notify ) == api_false )
      throw APIFunctionError( "SetViewPropertyValue" );
}
예제 #7
0
파일: View.cpp 프로젝트: SunGong1993/PCL
Variant View::ComputeProperty( const IsoString& property, bool notify )
{
   api_property_value value;
   if ( (*API->View->ComputeViewProperty)( ModuleHandle(), handle, property.c_str(), notify, &value ) == api_false )
      throw APIFunctionError( "ComputeViewProperty" );
   return VariantFromAPIPropertyValue( value );
}
예제 #8
0
파일: View.cpp 프로젝트: SunGong1993/PCL
Variant View::PropertyValue( const IsoString& property ) const
{
   api_property_value value;
   if ( (*API->View->GetViewPropertyValue)( ModuleHandle(), handle, property.c_str(), &value ) == api_false )
      throw APIFunctionError( "GetViewPropertyValue" );
   return VariantFromAPIPropertyValue( value );
}
예제 #9
0
bool FileFormatInstance::WriteColorFilterArray( const ColorFilterArray& cfa )
{
   try
   {
      if ( (*API->FileFormat->BeginColorFilterArrayEmbedding)( handle ) == api_false )
         return false;

      IsoString pattern = cfa.Pattern();
      pattern.EnsureUnique();
      String name = cfa.Name();
      name.EnsureUnique();

      bool ok = (*API->FileFormat->SetImageColorFilterArray)( handle,
                           pattern.c_str(), cfa.Width(), cfa.Height(), name.c_str() ) != api_false;

      if ( cfa.Pattern() != pattern || cfa.Name() != name )
         APIHackingAttempt( "WriteColorFilterArray" );

      (*API->FileFormat->EndColorFilterArrayEmbedding)( handle );
      return ok;
   }
   catch ( ... )
   {
      (*API->FileFormat->EndColorFilterArrayEmbedding)( handle );
      throw;
   }
}
예제 #10
0
bool FileFormatInstance::WriteProperty( const IsoString& property, const Variant& value )
{
   try
   {
      if ( (*API->FileFormat->BeginPropertyEmbedding)( handle ) == api_false )
         return false;

      bool ok = true;

      if ( value.IsValid() )
      {
         api_property_value apiValue;
         APIPropertyValueFromVariant( apiValue, value );
         api_property_value safeCopy = apiValue;
         ok = (*API->FileFormat->SetImageProperty)( handle, property.c_str(), &safeCopy ) != api_false;

         if ( safeCopy.data.blockValue != apiValue.data.blockValue ||
              safeCopy.dimX != apiValue.dimX || safeCopy.dimY != apiValue.dimY ||
              safeCopy.dimZ != apiValue.dimZ || safeCopy.dimT != apiValue.dimT || safeCopy.type != apiValue.type )
         {
            APIHackingAttempt( "WriteProperty" );
         }
      }

      (*API->FileFormat->EndPropertyEmbedding)( handle );

      return ok;
   }
   catch ( ... )
   {
      (*API->FileFormat->EndPropertyEmbedding)( handle );
      throw;
   }
}
예제 #11
0
bool FileFormatInstance::Open( ImageDescriptionArray& images,
                               const String& filePath, const IsoString& hints )
{
   images.Clear();

   if ( (*API->FileFormat->OpenImageFileEx)( handle, filePath.c_str(), hints.c_str(), 0/*flags*/ ) == api_false )
      return false;

   for ( uint32 i = 0, n = (*API->FileFormat->GetImageCount)( handle ); i < n; ++i )
   {
      IsoString id;
      size_type len = 0;
      (*API->FileFormat->GetImageId)( handle, 0, &len, i );
      if ( len > 0 )
      {
         id.SetLength( len );
         if ( (*API->FileFormat->GetImageId)( handle, id.Begin(), &len, i ) == api_false )
            throw APIFunctionError( "GetImageId" );
         id.ResizeToNullTerminated();
      }

      api_image_info info;
      api_image_options options;
      if ( (*API->FileFormat->GetImageDescription)( handle, &info, &options, i ) == api_false )
         throw APIFunctionError( "GetImageDescription" );

      ImageDescription d;
      d.id = id;
      APIImageInfoToPCL( d.info, info );
      APIImageOptionsToPCL( d.options, options );
      images.Add( d );
   }

   return true;
}
예제 #12
0
 void NumberProperty::addElement(IsoString elementName, IsoString value){
	 INumber* np = ((INumberVectorProperty*) m_property->getProperty())->np;
	 int nnp = ((INumberVectorProperty*) m_property->getProperty())->nnp;
	 np = (INumber*) realloc(np, (nnp+1) * sizeof(INumber));
	 CHECK_POINTER(np);
	 strcpy(np->name, elementName.c_str());
	 np->value = value.ToDouble();
	 np->nvp=(INumberVectorProperty*) m_property->getProperty();
	 ((INumberVectorProperty*) m_property->getProperty())->nnp++;
	 ((INumberVectorProperty*) m_property->getProperty())->np = np;
 }
예제 #13
0
String PropertyUtils::getFormattedNumber( String numberStr, IsoString numberFormat )
{
   if ( numberStr.IsEmpty() )
      return numberStr;

   size_t im = numberFormat.Find( 'm' );
   if ( im == String::notFound )
      return String().Format( numberFormat.c_str(), stringToFloatSafe( numberStr ) );

   numberFormat.DeleteRight( im );
   numberFormat.DeleteLeft( 1 );
   StringList tokens;
   numberFormat.Break( tokens, '.', true/*trim*/ );
   size_t fraction = stringToIntSafe( tokens[1] );
   size_t width    = stringToIntSafe( tokens[0] ) - fraction;
   assert( width > 0 );
   int hours = Trunc( stringToFloatSafe( numberStr ) );
   switch ( fraction )
   {
   case 3:
      {
         int minutes = Trunc( (stringToFloatSafe( numberStr ) - hours)*60 );
         IsoString formatStr = '%' + IsoString().Format( "%dd",width ) + ":%02d";
         return String().Format( formatStr.c_str(), hours, Abs( minutes ) );
      }
   case 5:
      {
         int minutes     = Trunc( (stringToFloatSafe( numberStr ) - hours)*60 );
         int minutesfrac = Trunc( ((stringToFloatSafe( numberStr ) - hours)*60 - minutes)*10);
         IsoString formatStr = '%' + IsoString().Format( "%dd", width ) + ":%02d.%d";
         return String().Format( formatStr.c_str(), hours, Abs( minutes ), Abs( minutesfrac ) );
      }
   case 6:
      {
         int minutes     = Trunc( (stringToFloatSafe( numberStr ) - hours)*60 );
         int seconds     = Trunc( ((stringToFloatSafe( numberStr ) - hours)*60 - minutes)*60 );
         IsoString formatStr = '%' + IsoString().Format( "%dd", width ) + ":%02d:%02d";
         return String().Format( formatStr.c_str(), hours, Abs( minutes ), Abs( seconds ) );
      }
   case 8:
      {
         int minutes     = Trunc( (stringToFloatSafe( numberStr ) - hours)*60 );
         int seconds     = Trunc( ((stringToFloatSafe( numberStr ) - hours)*60 - minutes)*60 );
         int secondsfrac = Trunc( (((stringToFloatSafe( numberStr ) - hours)*60 - minutes)*60 - seconds)*10 );
         IsoString formatStr = '%' + IsoString().Format( "%dd", width ) + ":%02d:%02d.%d";
         return String().Format( formatStr.c_str(), hours, Abs( minutes ), Abs( seconds ), Abs( secondsfrac ) );
      }
   case 9:
      {
         int minutes     = Trunc( (stringToFloatSafe( numberStr ) - hours)*60 );
         int seconds     = Trunc( ((stringToFloatSafe( numberStr ) - hours)*60 - minutes)*60 );
         int secondsfrac = Trunc( (((stringToFloatSafe( numberStr ) - hours)*60 - minutes)*60 - seconds)*100 );
         IsoString formatStr = '%' + IsoString().Format( "%dd", width ) + ":%02d:%02d.%02d";
         return String().Format( formatStr.c_str(), hours, Abs( minutes ), Abs( seconds ), Abs( secondsfrac ) );
      }
   default:
      return String();
   }
}
예제 #14
0
void SwitchProperty::addElement( IsoString elementName, IsoString value )
{
   ISwitchVectorProperty* svp = m_property->getSwitch();
   ISwitch* sp = svp->sp;
   int nsp = svp->nsp;
   sp = reinterpret_cast<ISwitch*>( realloc( sp, (nsp + 1)*sizeof( ISwitch ) ) );
   if ( sp == nullptr )
      throw std::bad_alloc();
   strcpy( sp->name, elementName.c_str() );
   sp->s = (value == "ON") ? ISS_ON : ISS_OFF;
   sp->svp = svp;
   svp->nsp++;
   svp->sp = sp;
}
예제 #15
0
void TextProperty::addElement( IsoString elementName, IsoString value )
{
   ITextVectorProperty* tvp = m_property->getText();
   IText* tp = tvp->tp;
   int ntp = tvp->ntp;
   tp = reinterpret_cast<IText*>( realloc( tp, (ntp + 1)* sizeof( IText ) ) );
   if ( tp == nullptr )
      throw std::bad_alloc();
   strcpy( tp->name, elementName.c_str() );
   tp->text = value.Release(); // N.B.: Can do this because value is being passed by value, so we have a local copy.
   tp->tvp = tvp;
   tvp->ntp++;
   tvp->tp = tp;
}
예제 #16
0
IsoString FileFormat::Name() const
{
   size_type len = 0;
   (*API->FileFormat->GetFileFormatName)( m_data->handle, 0, &len );

   IsoString name;
   if ( len > 0 )
   {
      name.SetLength( len );
      if ( (*API->FileFormat->GetFileFormatName)( m_data->handle, name.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetFileFormatName" );
      name.ResizeToNullTerminated();
   }
   return name;
}
예제 #17
0
파일: View.cpp 프로젝트: SunGong1993/PCL
IsoString View::FullId() const
{
   size_type len = 0;
   (*API->View->GetViewFullId)( handle, 0, &len );

   IsoString id;
   if ( len > 0 )
   {
      id.SetLength( len );
      if ( (*API->View->GetViewFullId)( handle, id.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetViewFullId" );
      id.ResizeToNullTerminated();
   }
   return id;
}
예제 #18
0
IsoString ProcessParameter::Id() const
{
   size_type len = 0;
   (*API->Process->GetParameterIdentifier)( m_data->handle, 0, &len );

   IsoString id;
   if ( len > 0 )
   {
      id.SetLength( len );
      if ( (*API->Process->GetParameterIdentifier)( m_data->handle, id.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetParameterIdentifier" );
      id.ResizeToNullTerminated();
   }
   return id;
}
예제 #19
0
bool ProcessInstance::ExecuteOn( ImageVariant& image, const IsoString& hints )
{
   if ( !image.IsSharedImage() || !image.IsCompletelySelected() )
   {
      ImageVariant tmp;
      tmp.CreateSharedImageAs( image ).AssignImage( image );
      if ( !ExecuteOn( tmp ) )
         return false;
      if ( image.IsCompletelySelected() )
         image.AssignImage( tmp );
      else
         image.Apply( tmp, ImageOp::Mov, image.SelectedRectangle().LeftTop() );
      return true;
   }

   return (*API->Process->ExecuteOnImage)( handle, image.SharedImageHandle(), hints.c_str(), 0/*flags*/ ) != api_false;
}
예제 #20
0
void NumberProperty::addElement( IsoString elementName, IsoString value )
{
   if ( !value.IsEmpty() )
   {
      INumberVectorProperty* nvp = m_property->getNumber();
      INumber* np = nvp->np;
      int nnp = nvp->nnp;
      np = reinterpret_cast<INumber*>( realloc( np, (nnp + 1)*sizeof( INumber ) ) );
      if ( np == nullptr )
         throw std::bad_alloc();
      strcpy( np->name, elementName.c_str() );
      value.TryToDouble( np->value );
      np->nvp = nvp;
      nvp->nnp++;
      nvp->np = np;
   }
}
예제 #21
0
IsoStringList ProcessParameter::Aliases() const
{
   size_type len = 0;
   (*API->Process->GetParameterAliasIdentifiers)( m_data->handle, 0, &len );

   IsoStringList aliases;
   if ( len > 0 )
   {
      IsoString csAliases;
      csAliases.SetLength( len );
      if ( (*API->Process->GetParameterAliasIdentifiers)( m_data->handle, csAliases.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetParameterAliasIdentifiers" );
      csAliases.ResizeToNullTerminated();
      csAliases.Break( aliases, ',' );
   }
   return aliases;
}
예제 #22
0
IsoStringList ProcessInstance::IconsByProcessId( const IsoString& processId )
{
   size_type len = 0;
   (*API->Process->EnumerateProcessIcons)( 0, 0, &len, 0 );

   ProcessIconsByProcessIdEnumerationData data( processId );

   if ( len != 0 )
   {
      IsoString iconId;
      iconId.Reserve( len );
      if ( (*API->Process->EnumerateProcessIcons)( InternalIconEnumerator::ProcessCallback,
                                          iconId.c_str(), &len, &data ) == api_false )
         throw APIFunctionError( "EnumerateProcessIcons" );
   }

   return data.icons;
}
예제 #23
0
IsoStringList ProcessInstance::Icons()
{
   size_type len = 0;
   (*API->Process->EnumerateProcessIcons)( 0, 0, &len, 0 );

   IsoStringList icons;

   if ( len != 0 )
   {
      IsoString iconId;
      iconId.Reserve( len );
      if ( (*API->Process->EnumerateProcessIcons)( InternalIconEnumerator::IconCallback,
                                          iconId.c_str(), &len, &icons ) == api_false )
         throw APIFunctionError( "EnumerateProcessIcons" );
   }

   return icons;
}
예제 #24
0
 void LightProperty::addElement(IsoString elementName, IsoString value) {
	ILight* lp = ((ILightVectorProperty*) m_property->getProperty())->lp;
	int nlp = ((ILightVectorProperty*) m_property->getProperty())->nlp;
	lp = (ILight*) realloc(lp, (nlp + 1) * sizeof(ILight));
	CHECK_POINTER(lp);
	strcpy(lp->name, elementName.c_str());
	if (value == "IDLE") {
		lp->s = IPS_IDLE;
	} else if (value == "OK") {
		lp->s = IPS_OK;
	} else if (value == "BUSY") {
		lp->s = IPS_BUSY;
	} else if (value == "ALERT") {
		lp->s = IPS_ALERT;
	} else {
		throw Error(ERR_MSG("Invalid property value;"));
	}
	lp->lvp = (ILightVectorProperty*) m_property->getProperty();
	((ILightVectorProperty*) m_property->getProperty())->nlp++;
	((ILightVectorProperty*) m_property->getProperty())->lp = lp;
}
예제 #25
0
void LightProperty::addElement( IsoString elementName, IsoString value )
{
   ILightVectorProperty* lvp = m_property->getLight();
   ILight* lp = lvp->lp;
   int nlp = lvp->nlp;
   lp = reinterpret_cast<ILight*>( realloc( lp, (nlp + 1)*sizeof( ILight ) ) );
   if ( lp == nullptr )
      throw std::bad_alloc();
   strcpy( lp->name, elementName.c_str() );
   if (value == "IDLE")
      lp->s = IPS_IDLE;
   else if (value == "OK")
      lp->s = IPS_OK;
   else if (value == "BUSY")
      lp->s = IPS_BUSY;
   else if (value == "ALERT")
      lp->s = IPS_ALERT;
   else
      throw Error( "INDIDeviceController: Internal error: Invalid property value in LightProperty::addElement()" );
   lp->lvp = lvp;
   lvp->nlp++;
   lvp->lp = lp;
}
예제 #26
0
파일: Color.cpp 프로젝트: AndresPozo/PCL
RGBA RGBAColor( const IsoString& colorName )
{
   if ( colorName.StartsWith( '#' ) )
   {
      size_type n = colorName.Length();

      int r, g, b, a;

      if ( n == 9 )        // "#RRGGBBAA" format
      {
         r = HexNibbleValue( colorName.Begin()+1 );
         g = HexNibbleValue( colorName.Begin()+3 );
         b = HexNibbleValue( colorName.Begin()+5 );
         a = HexNibbleValue( colorName.Begin()+7 );
      }
      else if ( n == 7 )   // "#RRGGBB" format
      {
         r = HexNibbleValue( colorName.Begin()+1 );
         g = HexNibbleValue( colorName.Begin()+3 );
         b = HexNibbleValue( colorName.Begin()+5 );
         a = 0xFF;
      }
      else
         return 0;

      if ( r < 0 || g < 0 || b < 0 || a < 0 )
         return 0;

      return RGBAColor( r, g, b, a );
   }

   if ( cssColors.IsEmpty() )
      InitCSSColors();

   css_color_collection::const_iterator i = cssColors.Search( CSSColor( colorName.c_str(), 0 ) );
   return (i != cssColors.End()) ? (*i).value : 0;
}
예제 #27
0
Variant FileFormatInstance::ReadProperty( const IsoString& property )
{
   try
   {
      if ( (*API->FileFormat->BeginPropertyExtraction)( handle ) == api_false )
         return Variant();

      api_property_value apiValue;
      if ( (*API->FileFormat->GetImageProperty)( handle, property.c_str(), &apiValue ) == api_false )
      {
         apiValue.data.blockValue = nullptr;
         apiValue.type = VTYPE_INVALID;
      }

      (*API->FileFormat->EndPropertyExtraction)( handle );

      return VariantFromAPIPropertyValue( apiValue );
   }
   catch ( ... )
   {
      (*API->FileFormat->EndPropertyExtraction)( handle );
      throw;
   }
}
예제 #28
0
ProcessInstance ProcessInstance::FromIcon( const IsoString& iconId )
{
   return ProcessInstance( (*API->Process->CreateProcessInstanceFromIcon)( ModuleHandle(), iconId.c_str() ) );
}
예제 #29
0
ProcessInstance ProcessInstance::FromSource( const String& source, const IsoString& language )
{
   return ProcessInstance( (*API->Process->CreateProcessInstanceFromSourceCode)( source.c_str(), language.c_str() ) );
}
예제 #30
0
ProcessParameter::enumeration_element_list ProcessParameter::EnumerationElements() const
{
   if ( !IsEnumeration() )
      return enumeration_element_list();

   size_type count = (*API->Process->GetParameterElementCount)( m_data->handle );
   if ( count == 0 )
      throw APIFunctionError( "GetParameterElementCount" );

   enumeration_element_list elements( count );

   for ( size_type i = 0; i < count; ++i )
   {
      size_type len = 0;
      (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, 0, &len );
      if ( len == 0 )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.SetLength( len );
      if ( (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, elements[i].id.c_str(), &len ) == api_false )
         throw APIFunctionError( "GetParameterElementIdentifier" );
      elements[i].id.ResizeToNullTerminated();

      len = 0;
      (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, 0, &len );
      if ( len > 0 )
      {
         IsoString aliases;
         aliases.SetLength( len );
         if ( (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, aliases.c_str(), &len ) == api_false )
            throw APIFunctionError( "GetParameterElementAliasIdentifiers" );
         aliases.ResizeToNullTerminated();
         aliases.Break( elements[i].aliases, ',' );
      }

      elements[i].value = (*API->Process->GetParameterElementValue)( m_data->handle, i );
   }

   return elements;
}