Exemple #1
0
void GmJobItem::CopyItem (const GmJobItem & item)
{
	szName		= item.szName;
	szDest		= item.szDest;
	szDesc		= item.szDesc;
	szPass		= item.szPass;
	Time		= item.Time;
	SplitSize	= item.SplitSize;
	MergeTimes	= item.MergeTimes;

	DeflateType = item.DeflateType;
	EncryptType = item.EncryptType;

	for_each (vpSources.begin (), vpSources.end (), ReleaseMemory ());
	vpSources.clear ();
	for (size_t index = 0; index < item.vpSources.size (); ++index)
		AddSource (item.vpSources[index]->szPath, item.vpSources[index]->Options);

	Filter = item.Filter;
	for_each (vpPlans.begin (), vpPlans.end (), ReleaseMemory ());
	vpPlans.clear ();
	for (size_t index = 0; index < item.vpPlans.size (); ++index)
		AddPlan (*item.vpPlans[index]);

	Options = item.Options;
}
void CImageCelsSource::AddDiskFileSource(char* szFileName, char* szImageName, CImageCelSource* pcCelSource)
{
	CImageSourceDiskFile*	pcDiskFile;
	int						iLen;
	CChars					szNewName;
	CFileUtil				cFileUtil;

	if (!szFileName)
	{
		return;
	}
	iLen = (int)strlen(szFileName);
	if (iLen == 0)
	{
		return;
	}

	pcDiskFile = UMalloc(CImageSourceDiskFile);

	if (szImageName)
	{
		pcDiskFile->Init(szFileName, szImageName);
	}
	else
	{
		szNewName.Init(szFileName);
		cFileUtil.RemovePath(&szNewName);
		pcDiskFile->Init(szFileName, szNewName.Text());
		szNewName.Kill();
	}
	AddSource(pcDiskFile, pcCelSource);
}
BOOL CDownloadWithSources::AddSourceHit(const CQueryHit* pHit, BOOL bForce)
{
	CQuickLock oLock( Transfers.m_pSection );

	if ( ! AddSource( pHit, bForce ) )
		return FALSE;

	if ( Settings.Downloads.Metadata && m_pXML == NULL && pHit->m_pXML && pHit->m_pSchema )
	{
		m_pXML = pHit->m_pSchema->Instantiate( TRUE );
		m_pXML->AddElement( pHit->m_pXML->Clone() );
		pHit->m_pSchema->Validate( m_pXML, TRUE );
	}

	//if ( pHit->m_nProtocol == PROTOCOL_ED2K )
	//	Neighbours.FindDonkeySources( pHit->m_oED2K,
	//		(IN_ADDR*)pHit->m_oClientID.begin(), (WORD)pHit->m_oClientID.begin()[1] );

	// No URL, stop now with success
	if ( ! pHit->m_sURL.IsEmpty() &&
		 ! AddSourceInternal( new CDownloadSource( (CDownload*)this, pHit ) ) )
		return FALSE;

	return TRUE;
}
Exemple #4
0
/**
 * @brief Compute the right-hand side.
 */
void APE::DoOdeRhs(const Array<OneD, const Array<OneD, NekDouble> >&inarray,
                         Array<OneD,       Array<OneD, NekDouble> >&outarray,
                   const NekDouble time)
{
    int nVariables = inarray.num_elements();
    int nq = GetTotPoints();
    Array<OneD, NekDouble> tmp1(nq);

    // WeakDG does not use advVel, so we only provide a dummy array
    Array<OneD, Array<OneD, NekDouble> > advVel(m_spacedim);
    m_advection->Advect(nVariables, m_fields, advVel, inarray, outarray, time);

    for (int i = 0; i < nVariables; ++i)
    {
        if (i ==  0)
        {
            // c^2 = gamma*p0/rho0
            Vmath::Vdiv(nq, m_basefield[0], 1, m_basefield[1], 1, tmp1, 1);
            Vmath::Smul(nq, m_gamma, tmp1, 1, tmp1, 1);
            Vmath::Vmul(nq, tmp1, 1, outarray[i], 1, outarray[i], 1);
        }

        Vmath::Neg(nq, outarray[i], 1);
    }

    AddSource(outarray);
}
void CImageCelsSource::AddMemorySource(CImage* pcImage, CImageCelSource* pcCelSource)
{
	CImageSourceMemory*		pcMemory;

	pcMemory = UMalloc(CImageSourceMemory);
	pcMemory->Init(pcImage);
	AddSource(pcMemory, pcCelSource);
}
Exemple #6
0
void Generator :: AddSources( const ALib::XMLElement * e ) {
	for ( unsigned int i = 0; i < e->ChildCount(); i++ ) {
		const ALib::XMLElement * ce = e->ChildElement( i );
		if ( ce ) {
			DataSource * ds  = TagDictionary::Instance()->CreateDS( ce );
			AddSource ( ds );
		}
	}
}
Exemple #7
0
static unsigned long static_AddExcept(int source, H3270 *session, void (*fn)(H3270 *session))
{
#if defined(_WIN32) /*[*/
	return 0;
#else
	Trace("Adding Except handle %08x",source);
	return AddSource(source,session,G_IO_HUP|G_IO_ERR,fn);
#endif
}
Exemple #8
0
  SortWayDataGenerator::SortWayDataGenerator()
  : SortDataGenerator<Way>(WayDataFile::WAYS_DAT,WayDataFile::WAYS_IDMAP)
  {
    AddSource(OptimizeAreaWayIdsGenerator::WAYS_TMP);

    AddFilter(std::make_shared<WayLocationProcessorFilter>());
    AddFilter(std::make_shared<WayNodeReductionProcessorFilter>());
    AddFilter(std::make_shared<WayTypeIgnoreProcessorFilter>());
  }
Exemple #9
0
static void SourceCallback(pa_context *ctx, const pa_source_info *i, int eol,
                           void *userdata)
{
    services_discovery_t *sd = userdata;

    if (eol)
        return;
    AddSource (sd, i);
    (void) ctx;
}
CPLErr VRTSourcedRasterBand::XMLInit( CPLXMLNode * psTree, 
                                      const char *pszVRTPath )

{
    CPLErr eErr;

    eErr = VRTRasterBand::XMLInit( psTree, pszVRTPath );
    if( eErr != CE_None )
        return eErr;
    
/* -------------------------------------------------------------------- */
/*      Validate a bit.                                                 */
/* -------------------------------------------------------------------- */
    if( psTree == NULL || psTree->eType != CXT_Element
        || (!EQUAL(psTree->pszValue,"VRTSourcedRasterBand") 
            && !EQUAL(psTree->pszValue,"VRTRasterBand")
	    && !EQUAL(psTree->pszValue,"VRTDerivedRasterBand")) )
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "Invalid node passed to VRTSourcedRasterBand::XMLInit()." );
        return CE_Failure;
    }

/* -------------------------------------------------------------------- */
/*      Process sources.                                                */
/* -------------------------------------------------------------------- */
    CPLXMLNode  *psChild;
    VRTDriver *poDriver = (VRTDriver *) GDALGetDriverByName( "VRT" );
    
    for( psChild = psTree->psChild; 
         psChild != NULL && poDriver != NULL; 
         psChild = psChild->psNext)
    {
        VRTSource *poSource;

        if( psChild->eType != CXT_Element )
            continue;

        CPLErrorReset();
        poSource = poDriver->ParseSource( psChild, pszVRTPath );
        if( poSource != NULL )
            AddSource( poSource );
        else if( CPLGetLastErrorType() != CE_None )
            return CE_Failure;
    }

/* -------------------------------------------------------------------- */
/*      Done.                                                           */
/* -------------------------------------------------------------------- */
    if( nSources == 0 )
        CPLDebug( "VRT", "No valid sources found for band in VRT file:\n%s",
                  pszVRTPath );

    return CE_None;
}
Exemple #11
0
/////////////////////////////////////////////////////////////////////////////////////////
// DefaultUnfoundedCheck - source pointer propagation
/////////////////////////////////////////////////////////////////////////////////////////
// propagates recently set source pointers within one strong component.
void DefaultUnfoundedCheck::propagateSource(bool forceTodo) {
    for (LitVec::size_type i = 0; i < sourceQ_.size(); ++i) {
        NodeId atom = sourceQ_[i];
        if (atoms_[atom].hasSource()) {
            // propagate a newly added source-pointer
            graph_->visitAtomSuccessors(atom, AddSource(this));
        }
        else {
            graph_->visitAtomSuccessors(atom, RemoveSource(this, forceTodo));
        }
    }
    sourceQ_.clear();
}
void CImageCelsSource::AddDiskFileSources(char* szPathName, char* szFileNameContains, char* szImageName, CImageCelSource* pcCelSource)
{
	CFileUtil				cFileUtil;
	CArrayString			cFileNames;
	int						i;
	CChars*					pszName;
	CImageSourceDiskFile*	pcDiskFile;
	CChars					szNiceName;
	int						iIndex;
	int						iLen;

	if (!szFileNameContains)
	{
		return;
	}
	iLen = (int)strlen(szFileNameContains);
	if (iLen == 0)
	{
		return;
	}

	cFileNames.Init(32);
	cFileUtil.FindFilesWithNameContaining(szPathName, szFileNameContains, &cFileNames, FALSE);

	for (i = 0; i < cFileNames.NumElements(); i++)
	{
		pszName = cFileNames.Get(i);
		pcDiskFile = UMalloc(CImageSourceDiskFile);

		if (szImageName)
		{
			szNiceName.Init(*pszName);
			cFileUtil.RemovePath(&szNiceName);
			cFileUtil.RemoveExtension(&szNiceName);
			iIndex = szNiceName.Find(0, szFileNameContains);
			iIndex += iLen;
			szNiceName.RemoveFromStart(iIndex);
			szNiceName.Insert(0, szImageName);

			pcDiskFile->Init(pszName->Text(), szNiceName.Text());
			szNiceName.Kill();
		}
		else
		{
			pcDiskFile->Init(pszName->Text());
		}
		AddSource(pcDiskFile, pcCelSource);
	}

	cFileNames.Kill();
}
/* poSrcBand is not the mask band, but the band from which the mask band is taken */
CPLErr VRTSourcedRasterBand::AddMaskBandSource( GDALRasterBand *poSrcBand,
                                                int nSrcXOff, int nSrcYOff,
                                                int nSrcXSize, int nSrcYSize,
                                                int nDstXOff, int nDstYOff,
                                                int nDstXSize, int nDstYSize )
{
/* -------------------------------------------------------------------- */
/*      Default source and dest rectangles.                             */
/* -------------------------------------------------------------------- */
    if( nSrcYSize == -1 )
    {
        nSrcXOff = 0;
        nSrcYOff = 0;
        nSrcXSize = poSrcBand->GetXSize();
        nSrcYSize = poSrcBand->GetYSize();
    }

    if( nDstYSize == -1 )
    {
        nDstXOff = 0;
        nDstYOff = 0;
        nDstXSize = nRasterXSize;
        nDstYSize = nRasterYSize;
    }

/* -------------------------------------------------------------------- */
/*      Create source.                                                  */
/* -------------------------------------------------------------------- */
    VRTSimpleSource* poSimpleSource = new VRTSimpleSource();
    poSimpleSource->SetSrcMaskBand( poSrcBand );
    poSimpleSource->SetSrcWindow( 0, 0, poSrcBand->GetXSize(), poSrcBand->GetYSize() );
    poSimpleSource->SetDstWindow( 0, 0, nRasterXSize, nRasterYSize );

/* -------------------------------------------------------------------- */
/*      Default source and dest rectangles.                             */
/* -------------------------------------------------------------------- */
    if ( nSrcXOff == nDstXOff && nSrcYOff == nDstYOff &&
         nSrcXSize == nDstXSize && nSrcYSize == nRasterYSize )
        bEqualAreas = TRUE;

/* -------------------------------------------------------------------- */
/*      If we can get the associated GDALDataset, add a reference to it.*/
/* -------------------------------------------------------------------- */
    if( poSrcBand->GetDataset() != NULL )
        poSrcBand->GetDataset()->Reference();

/* -------------------------------------------------------------------- */
/*      add to list.                                                    */
/* -------------------------------------------------------------------- */
    return AddSource( poSimpleSource );
}
Exemple #14
0
// Creates a new per-vertex data source
FCDGeometrySource* FCDGeometryMesh::AddVertexSource(FUDaeGeometryInput::Semantic type)
{
	FCDGeometrySource* vertexSource = AddSource(type);
	vertexSources.push_back(vertexSource);

	// Add this new per-vertex data source to all the existing polygon groups, at offset 0.
	size_t polygonsCount = polygons.size();
	for (size_t p = 0; p < polygonsCount; ++p)
	{
		polygons[p]->AddInput(vertexSource, 0);
	}

	SetNewChildFlag();
	return vertexSource;
}
OP_STATUS GadgetsTreeModel::Init()
{
	PlatformGadgetList* platform_gadget_list = NULL;
	RETURN_IF_ERROR(PlatformGadgetList::Create(&platform_gadget_list));
	OP_ASSERT(NULL != platform_gadget_list);
	m_platform_gadget_list.reset(platform_gadget_list);

	m_platform_polling_clock.SetTimerListener(this);

	// Add the default gadget source.
	m_sources.DeleteAll();
	RETURN_IF_ERROR(AddSource(OpAutoPtr<Source>(
					OP_NEW(PlatformSource, (*m_platform_gadget_list)))));

	return OpStatus::OK;
}
BOOL CDownloadWithSources::AddSourceHit(const CPeerProjectURL& oURL, BOOL bForce)
{
	CQuickLock oLock( Transfers.m_pSection );

	if ( ! AddSource( &oURL, bForce ) )
		return FALSE;

	if ( oURL.m_pTorrent )
		((CDownload*)this)->SetTorrent( oURL.m_pTorrent );

	if ( ! oURL.m_sURL.IsEmpty() &&
		 ! AddSourceURL( oURL.m_sURL ) )
		return FALSE;

	return TRUE;
}
CPLErr VRTSourcedRasterBand::SetMetadata( char **papszNewMD, const char *pszDomain )

{
    if( pszDomain != NULL
        && (EQUAL(pszDomain,"new_vrt_sources") 
            || EQUAL(pszDomain,"vrt_sources")) )
    {
        VRTDriver *poDriver = (VRTDriver *) GDALGetDriverByName( "VRT" );
        CPLErr eErr;
        int    i;

        if( EQUAL(pszDomain,"vrt_sources") )
        {
            for( int i = 0; i < nSources; i++ )
                delete papoSources[i];
            CPLFree( papoSources );
            papoSources = NULL;
            nSources = 0;
        }

        for( i = 0; i < CSLCount(papszNewMD); i++ )
        {
            const char *pszXML = CPLParseNameValue( papszNewMD[i], NULL );
            CPLXMLNode *psTree = CPLParseXMLString( pszXML );
            VRTSource *poSource;
            
            if( psTree == NULL )
                return CE_Failure;

            poSource = poDriver->ParseSource( psTree, NULL );
            CPLDestroyXMLNode( psTree );

            if( poSource != NULL )
            {
                eErr = AddSource( poSource );
                if( eErr != CE_None )
                    return eErr;
            }
            else
                return CE_Failure;
        }

        return CE_None;
    }
    else
        return VRTRasterBand::SetMetadata( papszNewMD, pszDomain );
}
CPLErr VRTSourcedRasterBand::AddFuncSource( VRTImageReadFunc pfnReadFunc, 
                                     void *pCBData, double dfNoDataValue )

{
/* -------------------------------------------------------------------- */
/*      Create source.                                                  */
/* -------------------------------------------------------------------- */
    VRTFuncSource *poFuncSource = new VRTFuncSource;

    poFuncSource->fNoDataValue = (float) dfNoDataValue;
    poFuncSource->pfnReadFunc = pfnReadFunc;
    poFuncSource->pCBData = pCBData;
    poFuncSource->eType = GetRasterDataType();

/* -------------------------------------------------------------------- */
/*      add to list.                                                    */
/* -------------------------------------------------------------------- */
    return AddSource( poFuncSource );
}
Exemple #19
0
int AudioHandlerAl::PlaySound(const std::string& resource, bool is_loop, float volume, float pitch)
{
  int buffer_ref = -1;
  
  std::map<std::string, int>::iterator itor = buffer_resource_map_.find(resource);
  if (itor != buffer_resource_map_.end())
  {
    buffer_ref = itor->second;
  }
  else
  {
    buffer_ref = AddBuffer(resource);
  }
  
#ifdef AUDIO_LOG
  fprintf(stdout, "PlaySound %s buffer %d\n", resource.c_str(), buffer_ref);
#endif

  return AddSource(buffer_ref, is_loop, volume, pitch);
}
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tSuzukiRepowerEnginePanel::CreateActions()
{
    m_pSpacerAct = new tAction( this );

    m_pEditAct = new tAction( tr( "Edit" ) + "...", this );
    m_pEditAct->SetAbbreviation( tr( "Edit", "[abbrev] for Edit" ) );
    Connect( m_pEditAct, SIGNAL( triggered() ), this, SLOT( EnterEditMode() ) );

    m_pSaveAct = new tAction( tr( "Save", "[button]" ), this );
    m_pSaveAct->SetAbbreviation( tr( "Save", "[abbrev] for Save" ) );
    Connect( m_pSaveAct, SIGNAL( triggered() ), this, SLOT( EditSave() ) );

    m_pCancelAct = new tAction( tr( "Cancel", "[button]" ), this );
    m_pCancelAct->SetAbbreviation( tr( "Cancel", "[abbrev] for Cancel" ) );
    m_pCancelAct->SetAppearance( Action::DestructiveAppearance );
    Connect( m_pCancelAct, SIGNAL( triggered() ), this, SLOT( EditCancel() ), Qt::QueuedConnection );

    m_pChangeGaugeRangeAct = new tAction( tr( "Configure limits", "[button]" ) + "..." );
    m_pChangeGaugeRangeAct->SetAbbreviation( tr( "Config. limits", "[abbrev] for Configure limits" ) );
    Connect( m_pChangeGaugeRangeAct, SIGNAL( triggered() ), this, SLOT( ConfigureGaugeLimits() ) );

    m_pSelectDataAct = new tAction( tr( "Select info" ) + "..." );
    m_pSelectDataAct->SetAbbreviation( tr( "Select info", "[abbrev] for Select information" ) );
    Connect( m_pSelectDataAct, SIGNAL( triggered() ), this, SLOT( SelectInfo() ) );

    m_pAddSourceAct = new tAction( tr( "Add" ) );
    m_pAddSourceAct->SetAbbreviation( tr( "Add", "[abbrev] for Add" ) );
    m_pRemoveSourceAct = new tAction( tr( "Remove" ) );
    m_pRemoveSourceAct->SetAbbreviation( tr( "Remove", "[abbrev] for Remove" ) );
    m_pAutoAct = new tAction( tr( "Auto" ), this );
    m_pAutoAct->SetAbbreviation( tr( "Auto", "[abbrev] for Auto" ) );
    m_pAutoAct->setCheckable( true );

    m_pSourceMenuAct = new tAction( tr("Sources"), tr( "Sources", "[abbrev] for Sources" ), this );
    m_pSourceMenuAct->AppendSubAction( m_pAddSourceAct );
    m_pSourceMenuAct->AppendSubAction( m_pRemoveSourceAct );
    m_pSourceMenuAct->AppendSubAction( m_pAutoAct );
    Connect( m_pAddSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( AddSource() ) );
    Connect( m_pRemoveSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( RemoveSource() ), Qt::QueuedConnection );
    Connect( m_pAutoAct, SIGNAL( toggled( bool ) ), m_pPageWidget, SLOT( SetAutoConfigureSources( bool ) ) );
}
Exemple #21
0
JSDSourceText*
jsd_NewSourceText(JSDContext* jsdc, const char* url)
{
    JSDSourceText* jsdsrc;
    const char* new_url_string;

    jsd_LockSourceTextSubsystem(jsdc);

    new_url_string = jsd_BuildNormalizedURL(url);
    if( ! new_url_string )
        return NULL;

    jsdsrc = jsd_FindSourceForURL(jsdc, new_url_string);

    if( jsdsrc )
        MoveSourceToRemovedList(jsdc, jsdsrc);

    jsdsrc = AddSource( jsdc, new_url_string );

    jsd_UnlockSourceTextSubsystem(jsdc);

    return jsdsrc;
}
CPLErr VRTSourcedRasterBand::SetMetadataItem( const char *pszName, 
                                              const char *pszValue, 
                                              const char *pszDomain )

{
    CPLDebug( "VRT", "VRTSourcedRasterBand::SetMetadataItem(%s,%s,%s)\n",
              pszName, pszValue, pszDomain );
              
    if( pszDomain != NULL
        && EQUAL(pszDomain,"new_vrt_sources") )
    {
        VRTDriver *poDriver = (VRTDriver *) GDALGetDriverByName( "VRT" );

        CPLXMLNode *psTree = CPLParseXMLString( pszValue );
        VRTSource *poSource;
        
        if( psTree == NULL )
            return CE_Failure;
        
        poSource = poDriver->ParseSource( psTree, NULL );
        CPLDestroyXMLNode( psTree );
        
        if( poSource != NULL )
            return AddSource( poSource );
        else
            return CE_Failure;
    }
    else if( pszDomain != NULL
        && EQUAL(pszDomain,"vrt_sources") )
    {
        int iSource;
        if (sscanf(pszName, "source_%d", &iSource) != 1 || iSource < 0 ||
            iSource >= nSources)
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                     "%s metadata item name is not recognized. "
                     "Should be between source_0 and source_%d",
                     pszName, nSources - 1);
            return CE_Failure;
        }

        VRTDriver *poDriver = (VRTDriver *) GDALGetDriverByName( "VRT" );

        CPLXMLNode *psTree = CPLParseXMLString( pszValue );
        VRTSource *poSource;
        
        if( psTree == NULL )
            return CE_Failure;
        
        poSource = poDriver->ParseSource( psTree, NULL );
        CPLDestroyXMLNode( psTree );
        
        if( poSource != NULL )
        {
            delete papoSources[iSource];
            papoSources[iSource] = poSource;
            ((VRTDataset *)poDS)->SetNeedsFlush();
            return CE_None;
        }
        else
            return CE_Failure;
    }
    else
        return VRTRasterBand::SetMetadataItem( pszName, pszValue, pszDomain );
}
CPLErr VRTSourcedRasterBand::AddComplexSource( GDALRasterBand *poSrcBand, 
                                               int nSrcXOff, int nSrcYOff, 
                                               int nSrcXSize, int nSrcYSize, 
                                               int nDstXOff, int nDstYOff, 
                                               int nDstXSize, int nDstYSize,
                                               double dfScaleOff,
                                               double dfScaleRatio,
                                               double dfNoDataValue,
                                               int nColorTableComponent)

{
/* -------------------------------------------------------------------- */
/*      Default source and dest rectangles.                             */
/* -------------------------------------------------------------------- */
    if( nSrcYSize == -1 )
    {
        nSrcXOff = 0;
        nSrcYOff = 0;
        nSrcXSize = poSrcBand->GetXSize();
        nSrcYSize = poSrcBand->GetYSize();
    }

    if( nDstYSize == -1 )
    {
        nDstXOff = 0;
        nDstYOff = 0;
        nDstXSize = nRasterXSize;
        nDstYSize = nRasterYSize;
    }

/* -------------------------------------------------------------------- */
/*      Create source.                                                  */
/* -------------------------------------------------------------------- */
    VRTComplexSource *poSource;

    poSource = new VRTComplexSource();

    poSource->SetSrcBand( poSrcBand );
    poSource->SetSrcWindow( nSrcXOff, nSrcYOff, nSrcXSize, nSrcYSize );
    poSource->SetDstWindow( nDstXOff, nDstYOff, nDstXSize, nDstYSize );

/* -------------------------------------------------------------------- */
/*      Set complex parameters.                                         */
/* -------------------------------------------------------------------- */
    if( dfNoDataValue != VRT_NODATA_UNSET )
        poSource->SetNoDataValue( dfNoDataValue );

    if( dfScaleOff != 0.0 || dfScaleRatio != 1.0 )
    {
        poSource->bDoScaling = TRUE;
        poSource->dfScaleOff = dfScaleOff;
        poSource->dfScaleRatio = dfScaleRatio;
          
    }

    poSource->nColorTableComponent = nColorTableComponent;

/* -------------------------------------------------------------------- */
/*      If we can get the associated GDALDataset, add a reference to it.*/
/* -------------------------------------------------------------------- */
    if( poSrcBand->GetDataset() != NULL )
        poSrcBand->GetDataset()->Reference();

/* -------------------------------------------------------------------- */
/*      add to list.                                                    */
/* -------------------------------------------------------------------- */
    return AddSource( poSource );
}
CPLErr VRTSourcedRasterBand::AddSimpleSource( GDALRasterBand *poSrcBand, 
                                       int nSrcXOff, int nSrcYOff, 
                                       int nSrcXSize, int nSrcYSize, 
                                       int nDstXOff, int nDstYOff, 
                                       int nDstXSize, int nDstYSize,
                                       const char *pszResampling, 
                                       double dfNoDataValue )

{
/* -------------------------------------------------------------------- */
/*      Default source and dest rectangles.                             */
/* -------------------------------------------------------------------- */
    if( nSrcYSize == -1 )
    {
        nSrcXOff = 0;
        nSrcYOff = 0;
        nSrcXSize = poSrcBand->GetXSize();
        nSrcYSize = poSrcBand->GetYSize();
    }

    if( nDstYSize == -1 )
    {
        nDstXOff = 0;
        nDstYOff = 0;
        nDstXSize = nRasterXSize;
        nDstYSize = nRasterYSize;
    }

/* -------------------------------------------------------------------- */
/*      Create source.                                                  */
/* -------------------------------------------------------------------- */
    VRTSimpleSource *poSimpleSource;

    if( pszResampling != NULL && EQUALN(pszResampling,"aver",4) )
        poSimpleSource = new VRTAveragedSource();
    else
    {
        poSimpleSource = new VRTSimpleSource();
        if( dfNoDataValue != VRT_NODATA_UNSET )
            CPLError( 
                CE_Warning, CPLE_AppDefined, 
                "NODATA setting not currently supported for nearest\n"
                "neighbour sampled simple sources on Virtual Datasources." );
    }

    poSimpleSource->SetSrcBand( poSrcBand );
    poSimpleSource->SetSrcWindow( nSrcXOff, nSrcYOff, nSrcXSize, nSrcYSize );
    poSimpleSource->SetDstWindow( nDstXOff, nDstYOff, nDstXSize, nDstYSize );

    if( dfNoDataValue != VRT_NODATA_UNSET )
        poSimpleSource->SetNoDataValue( dfNoDataValue );

/* -------------------------------------------------------------------- */
/*      Default source and dest rectangles.                             */
/* -------------------------------------------------------------------- */
    if ( nSrcXOff == nDstXOff && nSrcYOff == nDstYOff &&
         nSrcXSize == nDstXSize && nSrcYSize == nRasterYSize )
        bEqualAreas = TRUE;

/* -------------------------------------------------------------------- */
/*      If we can get the associated GDALDataset, add a reference to it.*/
/* -------------------------------------------------------------------- */
    if( poSrcBand->GetDataset() != NULL )
        poSrcBand->GetDataset()->Reference();

/* -------------------------------------------------------------------- */
/*      add to list.                                                    */
/* -------------------------------------------------------------------- */
    return AddSource( poSimpleSource );
}
// 100625 ONS 분해시 우클릭으로 아이템이동 가능하도록 수정.
void CDissolveDialog::MoveIcon( CItem* movedItem )
{
	// 완료된 결과가 있을 경우 초기화시킨다
	{
		CItem* const item = (CItem*)mSourceDialog->GetIconForIdx(
			0);

		if(item->IsLocked())
		{
			Clear();
		}
	}

	if( 0 == movedItem )
	{
		return;
	}
	else if(WT_ITEM != movedItem->GetType())
	{
		return;
	}
	else if(movedItem->IsLocked())
	{
		return;
	}
	else if(FALSE == ITEMMGR->IsEqualTableIdxForPos(eItemTable_Inventory, movedItem->GetPosition()))
	{
		CHATMGR->AddMsg(
			CTC_SYSMSG,
			CHATMGR->GetChatMsg(787));
		return;
	}

	const Error error = IsEnableUpdate(movedItem->GetItemBaseInfo());
	if(ErrorNone != error)
	{
		PutError(
			error,
			movedItem->GetItemIdx());
		return;
	}

	WORD wEmptyPos = 0;
	for(WORD cellIndex = 0; mSourceDialog->GetCellNum() > cellIndex; ++cellIndex)
	{
		CItem* const item = (CItem*)mSourceDialog->GetIconForIdx(
			cellIndex);

		if(0 == item->GetItemIdx())
		{
			wEmptyPos = cellIndex;
			break;
		}
	}

	AddSource(
		movedItem->GetItemBaseInfo(),
		POSTYPE(wEmptyPos));
	AddResult(
		movedItem->GetItemBaseInfo());

	mSubmitButton->SetActive(
		TRUE);
}
Exemple #26
0
main(int   argc,
     char  **argv)
{
    extern int	    optind;	/* for use of getopt() */
    extern char	    *optarg;	/* for use of getopt() */
    int		    ch;		/* command-line option letter */

    int		    outarch = NATIVE;

    char	    **field_names = NULL;
    int		    num_fields = 0;
    int		    alloc_fields = 0;

    int		    rflag = NO;	/* -r option specified? */
    char	    *rrange;	/* arguments of -r option */
    long	    start_rec;	/* starting record number */
    long	    end_rec;	/* ending record number */
    long	    num_recs;	/* number of records to read
				   (0 means all up to end of file) */
    long	    num_read;	/* number of records actually read */

    int		    Aflag = NO;	/* annotate Ascii output? */
    Annot	    *annotate = NULL;
    int		    annwidth = 70;

    char	    *iname;	/* input file name */
    FILE	    *ifile;	/* input stream */
    struct header   *ihd;	/* input file header */
    struct fea_data *irec;	/* input record */

    char	    *oname;	/* output file name */
    FILE	    *ofile;	/* output stream */
    FieldList	    list;	/* output field list */
    int		    outord = TYPE_ORDER;
    FieldSpec	    **ofields;	/* output fields in field or type order */

    double	    rec_freq;
    double	    start_time_offset;
    char	    *fdata;
    double	    *edata;
    int		    type;
    int		    len, i;
    long	    dim[1];
    FieldSpec	    *field;

    FieldList	    source;	/* field list of source file */

    while ((ch = getopt(argc, argv, "a:f:r:x:A:F")) != EOF)
	switch (ch)
	{
	case 'a':
	    outarch = ((!strcmp(optarg, "EDR1")) ? EDR1
		       : (!strcmp(optarg, "EDR2")) ? EDR2
		       : (!strcmp(optarg, "NATIVE")) ? NATIVE
		       : (!strcmp(optarg, "ASCII")) ? ASCII
		       : UNKNOWN);
	    break;
	case 'f':
	    if (num_fields >= alloc_fields)
	    {
		size_t	size;

		alloc_fields = num_fields + 1 + num_fields/2;
		size = (alloc_fields + 1) * sizeof(char *);
		field_names = (char **)
		    ((field_names == NULL)
		     ? malloc(size)
		     : realloc(field_names, size));
	    }
	    field_names[num_fields++] = optarg;
	    field_names[num_fields] = NULL;
	    break;
	case 'r':
	    rflag = YES;
	    rrange = optarg;
	    break;
	case 'x':
	    debug_level = atoi(optarg);
	    break;
	case 'A':
	    Aflag = YES;
	    annwidth = atoi(optarg);
	    break;
	case 'F':
	    outord = FIELD_ORDER;
	    break;
	default:
	    SYNTAX;
	    break;
	}

    if (argc - optind > 2)
    {
	fprintf(stderr,
		"%s: too many file names specified.\n", ProgName);
	SYNTAX;
    }
    if (argc - optind < 2)
    {
	fprintf(stderr,
		"%s: too few file names specified.\n", ProgName);
	SYNTAX;
    }

    iname = eopen(ProgName,
		  argv[optind++], "r", FT_FEA, NONE, &ihd, &ifile);

    oname = argv[optind++];

    start_rec = 1;
    end_rec = LONG_MAX;
    num_recs = 0;

    if (rflag)
    {
	lrange_switch(rrange, &start_rec, &end_rec, 0);
	if (end_rec != LONG_MAX)
	    num_recs = end_rec - start_rec + 1;
    }

    REQUIRE(start_rec >= 1, "can't start before beginning of file");
    REQUIRE(end_rec >= start_rec, "empty range of records specified");

    if (debug_level)
	fprintf(stderr,
		"start_rec: %ld.  end_rec: %ld.  num_recs: %ld.\n",
		start_rec, end_rec, num_recs);

    DebugMsgLevel = debug_level;
    DebugMsgFunc = DebugPrint;

    irec = allo_fea_rec(ihd);

    REQUIRE(irec != NULL, "can't allocate memory for input record");

    list = fea_to_FieldList(ihd, irec, field_names, FALSE);

    REQUIRE(list != NULL,
	    "failure converting input header to field list");

    switch (outord)
    {
    case TYPE_ORDER:
	if (debug_level)
	    fprintf(stderr, "making type-ordered field array.\n");
	ofields = TypeOrder(list);
	break;
    case FIELD_ORDER:
	if (debug_level)
	    fprintf(stderr, "making field-ordered field array.\n");
	ofields = FieldOrder(list);
	break;
    default:
	REQUIRE(0, "output order neither TYPE_ORDER nor FIELD_ORDER");
	break;
    }

    if (debug_level)
	fprintf(stderr, "setting field ordering.\n");

    REQUIRE(SetFieldOrdering(&list, outord),
	    "can't set field ordering of output");

    rec_freq = get_genhd_val("record_freq", ihd, 1.0);

    type = genhd_type("record_freq", &len, ihd);

    if (type != HD_UNDEF)
    {
	field = AddGlobalField(&list, "recordFreq", 0, NULL, EDOUBLE, NULL);
	*(double *) field->data = rec_freq;
    }

    type = genhd_type("start_time", &len, ihd);

    if (type != HD_UNDEF && rec_freq != 0)
    {
	start_time_offset = (start_rec - 1) / rec_freq;

	fdata = (char *) get_genhd("start_time", ihd);
	edata = (double *) type_convert((long) len, fdata, type,
					(char *) NULL, DOUBLE,
					(void (*)()) NULL);

	if (start_time_offset != 0)
	{
	    for (i = 0; i < len; i++)
		edata[i] += start_time_offset;
	}

	dim[0] = len;
	AddGlobalField(&list, "startTime", 1, dim, EDOUBLE, edata);
    }

    source = fea_to_FieldList(ihd, NULL, NULL, TRUE);
    (void) AddSource(&list, 0, iname, source);

    (void) AddCommandLine(&list, GetCommandLine(argc, argv));

    if (debug_level)
	fprintf(stderr, "annwidth %d.\n", annwidth);

    if (Aflag)
    {
	annotate = (Annot *) malloc(sizeof(Annot));
	annotate->position = 0;
	annotate->indent = 0;
	annotate->width = annwidth;
	annotate->recnum = 0;
    }

    if (debug_level)
	fprintf(stderr, "writing Esignal header.\n");

    REQUIRE(OpenOut(oname, list, outarch, &ofile, annotate),
	    "write header failed");
    if (ofile == stdout)
	oname = "<stdout>";

    num_read = start_rec - 1;

    if (debug_level)
	fprintf(stderr, "skipping %ld records.\n", num_read);

/*    skiprec(ifile, num_read, size_rec(ihd)); */
    fea_skiprec(ifile, num_read, ihd);

    while (num_read++ < end_rec && get_fea_rec(irec, ihd, ifile) != EOF)
    {
	if (debug_level > 2)
	    fprintf(stderr, "Record number %ld read.\n", num_read);

	WriteRecord(ofields, outarch, ofile, annotate);
    }

    if (--num_read < end_rec && num_recs != 0)
	fprintf(stderr, "fea2esig: only %ld records read.\n",
		num_read - (start_rec - 1));

    exit(0);
    /*NOTREACHED*/
}
Exemple #27
0
static FieldList
fea_to_FieldList(struct header	    *hdr,
		 struct fea_data    *rec,
		 char		    **field_names,
		 int		    copy_sources)
{
    struct fea_header	*fea;
    FieldList		list;
    int			i, j;
    FieldSpec		*field, *subfield;
    char		*name;
    int			spstype;
    long		*dim;
    int			rank;
    int			type;
    char		**codes;
    char		**gnames;
    int			gnum;
    struct varsize	*var;
    int			nsrc;
    FieldList		source;
    char		*line;
    long		len;


    if (hdr == NULL)
	return NULL;

    if (hdr->common.type != FT_FEA)
	return NULL;

    fea = hdr->hd.fea;

    list = NULL;

    if (hdr->common.tag && FindStr(ESPS_TAG, field_names))
    {
	field = NewFieldSpec(ELONG, 0);
	field->name = savestring(ESPS_TAG);
	field->occurrence = REQUIRED;
	if (rec != NULL)
	    field->data = &rec->tag;
	AddField(&list, field);
    }

    if (debug_level)
	fprintf(stderr, "fea_to_FieldList: field count %d.\n",
		fea->field_count);

    for (i = 0; i < (int) fea->field_count; i++)
    {
	long	size;

	name = fea->names[i];

	if (FindStr(name, field_names))
	{
	    spstype = fea->types[i];
	    size = fea->sizes[i];
	    rank = fea->ranks[i];
	    dim = fea->dimens[i];

	    if (debug_level >= 2)
		fprintf(stderr,
			"fea_to_FieldList: field[%d]: \"%s\".\n",
			i, name);

	    type = EspsTypeToElib(spstype);
	    field = NewFieldSpec(type, rank);
	    if (rank == 1)
		field->dim[0] = size;
	    else
		for (j = 0; j < rank; j++)
		    field->dim[j] = dim[j];
	    field->name = savestring(name);
	    field->occurrence = REQUIRED;
	    if (spstype == CODED)
	    {
		codes = fea->enums[i];
		subfield = NewFieldSpec(ECHAR, 2);
		subfield->name = savestring("enumStrings");
		subfield->occurrence = GLOBAL;
		StrArrToRect(codes, &subfield->dim, &subfield->data);
		AddSubfield(field, subfield);
	    }
	    if (rec != NULL)
		field->data = get_fea_ptr(rec, name, hdr);
	    AddField(&list, field);
	}
    }

    gnames = genhd_list(&gnum, hdr);

    for (i = 0; i < gnum; i++)
    {
	int	size;

	name = gnames[i];
	spstype = genhd_type(name, &size, hdr);

	if (debug_level >= 2)
	    fprintf(stderr,
		    "fea_to_FieldList: global field[%d]: \"%s\".\n",
		    i, name);

	type = EspsTypeToElib(spstype);
	field = NewFieldSpec(type, 1);
	field->dim[0] = size;
	field->name = savestring(name);
	field->occurrence = GLOBAL;
	if (spstype == CODED)
	{
	    codes = genhd_codes(name, hdr);
	    subfield = NewFieldSpec(ECHAR, 2);
	    subfield->name = savestring("enumStrings");
	    subfield->occurrence = GLOBAL;
	    StrArrToRect(codes, &subfield->dim, &subfield->data);
	    AddSubfield(field, subfield);
	}
	field->data = get_genhd(name, hdr);
	AddField(&list, field);
    }

    if (fea->fea_type != NONE)
    {
	field = AddGlobalField(&list, "FeaSubtype",
			       0, NULL, ESHORT, NULL);
	*(short *) field->data = fea->fea_type;
	subfield = NewFieldSpec(ECHAR, 2);
	subfield->name = savestring("enumStrings");
	subfield->occurrence = GLOBAL;
	StrArrToRect(fea_file_type, &subfield->dim, &subfield->data);
	AddSubfield(field, subfield);
    }

    var = &hdr->variable;

    if (copy_sources)
    {
	nsrc = MAX(var->nnames, var->nheads);
	for (i = 0; i < nsrc; i++)
	{
	    source = (i >= var->nheads) ? NULL
		: fea_to_FieldList(var->srchead[i], NULL, NULL, TRUE);
	    name = (i >= var->nnames) ? NULL
		: var->source[i];
	    (void) AddSource(&list, i, name, source);
	}
    }

    if (var->comment != NULL)
    {
	line = savestring(var->comment);
	len = strlen(line);
	if (line[len-1] == '\n')
	    line[len-1] = '\0';
	(void) AddCommandLine(&list, line);
    }

    return list;
}
BOOL CDissolveDialog::FakeMoveIcon(LONG x, LONG y, cIcon* movedIcon)
{
	// 완료된 결과가 있을 경우 초기화시킨다
	{
		CItem* const item = (CItem*)mSourceDialog->GetIconForIdx(
			0);

		if(item->IsLocked())
		{
			Clear();
		}
	}

	CItem* const movedItem = (CItem*)movedIcon;

	if(0 == movedItem)
	{
		return FALSE;
	}
	else if(WT_ITEM != movedItem->GetType())
	{
		return FALSE;
	}
	else if(movedItem->IsLocked())
	{
		return FALSE;
	}
	else if(FALSE == ITEMMGR->IsEqualTableIdxForPos(eItemTable_Inventory, movedItem->GetPosition()))
	{
		CHATMGR->AddMsg(
			CTC_SYSMSG,
			CHATMGR->GetChatMsg(787));
		return FALSE;
	}

	// 기존 아이템이 위치한 장소에 놓았을 경우 교체한다
	const POINT point = {x, y};
	CItem* const item = GetSourceItem(
		point);

	if(0 == item)
	{
		return FALSE;
	}
	else if(0 < item->GetItemIdx())
	{
		RemoveSource(
			item->GetItemBaseInfo(),
			POSTYPE(item->GetData()));
		RemoveResult(
			item->GetItemBaseInfo());
		Clear(
			*item);
	}

	const Error error = IsEnableUpdate(movedItem->GetItemBaseInfo());

	if(ErrorNone != error)
	{
		PutError(
			error,
			movedItem->GetItemIdx());
		return FALSE;
	}

	AddSource(
		movedItem->GetItemBaseInfo(),
		POSTYPE(item->GetData()));
	AddResult(
		movedItem->GetItemBaseInfo());

	mSubmitButton->SetActive(
		TRUE);
	return FALSE;
}
Exemple #29
0
/*---[ Implement ]-----------------------------------------------------------------------------------------*/

static unsigned long AddSource(int source, H3270 *session, gushort events, void (*fn)(H3270 *session))
{
	IO_Source *src = (IO_Source *) g_source_new(&IOSources,sizeof(IO_Source));

	src->source			= source;
	src->fn				= fn;
	src->poll.fd		= source;
	src->poll.events	= events;

	g_source_attach((GSource *) src,NULL);
	g_source_add_poll((GSource *) src,&src->poll);

	return (unsigned long) src;
}

static unsigned long static_AddInput(int source, H3270 *session, void (*fn)(H3270 *session))
{
	Trace("Adding Input handle %08x",source);
	return AddSource(source,session,G_IO_IN|G_IO_HUP|G_IO_ERR,fn);
}

static void static_RemoveSource(unsigned long id)
{
	if(id)
	{
		Trace("Removing input %p",(void *) id);
		g_source_destroy((GSource *) id);
	}
}

#if !defined(_WIN32) /*[*/
static unsigned long static_AddOutput(int source, H3270 *session, void (*fn)(H3270 *session))
{
	Trace("Adding Output handle %08x",source);
	return AddSource(source,session,G_IO_OUT|G_IO_HUP|G_IO_ERR,fn);
}