Пример #1
0
void RadialPlot::ScanTree(void const *node, unsigned int level, double startAngle, double endAngle)
{
	if (numItems >= maxNumItems)
		Grow();


	if (autoLevel && level > maxLevel)
		maxLevel = level;
		
	items[numItems].handle = node;
	items[numItems].level = level;
	items[numItems].startAngle = startAngle;
	items[numItems].endAngle = endAngle;
	items[numItems].id = GetId(node);
	items[numItems].color = GenerateElementColor(node);
	numItems++;

	int numChildren = GetNumChildren(node);
	unsigned int value = GetValue(node);
	double cAngle = startAngle;
	for (int i =0; i < numChildren ; i++)
	{
		void const *child = GetChild(node, i);
		unsigned int cValue = GetValue(child);
		double arc = (endAngle - startAngle) * cValue / value;
		ScanTree(child, level + 1, cAngle, cAngle + arc);
		cAngle += arc;
	}
}
Пример #2
0
void RadialPlot::RefreshTree(void const *startNode, int _maxLevel, int _maxValue)
{
	if (!startNode)
		startNode = GetRootNode();

	if (!startNode)
		return;

	numItems = 0;

	maxLevel = _maxLevel;

	autoLevel = !maxLevel;

	maxValue  = _maxValue;

	unsigned int val = GetValue(startNode);


	if (!val)
		val = 1;

	if (val > maxValue)
	{
		maxValue = val;
	}

	ScanTree(startNode, 0, 0, M_PI * 2 * val / maxValue);
}
Пример #3
0
int _CRTAPI1
main(
    IN int argc,
    IN char *argv[]
    )
{
    NET_API_STATUS       ApiStatus;
    int                  ArgNumber;
    BOOL                 DoingFiles = TRUE;
    REPL_WIN32_FIND_DATA FindData;
    BOOL                 GotPath = FALSE;
    LONG                 MasterTimeZoneOffsetSecs;  // exporter offset from GMT
    CHECKSUM_REC         Record;
    TCHAR                Source[ PATHLEN+1 ];   // area after L'\0' is scratch
    LPTSTR               UncServerName = NULL;  // server where files are.
    BOOL                 Verbose = FALSE;


    //
    // Process command-line arguments.
    //
    for (ArgNumber = 1; ArgNumber < argc; ArgNumber++) {
        if ((*argv[ArgNumber] == '-') || (*argv[ArgNumber] == '/')) {
            switch (tolower(*(argv[ArgNumber]+1))) // Process switches
            {

            case 'd' :
                DoingFiles = FALSE;
                break;

            case 's' :
                if (UncServerName != NULL) {
                    Usage( argv[0] );
                    return (EXIT_FAILURE);
                }
                UncServerName
                        = NetpAllocTStrFromStr( (LPSTR) argv[++ArgNumber]);
                NetpAssert( UncServerName != NULL );
                break;

            case 'v' :
                ReplGlobalTrace = REPL_DEBUG_ALL;
                Verbose = TRUE;
                break;

            default :
                Usage( argv[0] );
                return (EXIT_FAILURE);

            } // switch

        } else {  // not an argument

            if (GotPath) {
                Usage( argv[0] );
                return (EXIT_FAILURE);
            }
            GotPath = TRUE;
            (VOID) NetpCopyStrToTStr(Source, argv[ArgNumber]);
        }
    }

    if ( !GotPath ) {
        Usage( argv[0] );
        return (EXIT_FAILURE);
    }

    assert( Source[0] != TCHAR_EOS );

    //
    // Checksum is based on master's timezone, so get it.
    //
    ApiStatus = ReplGetTimeCacheValue(
            UncServerName,
            &MasterTimeZoneOffsetSecs ); // offset (+ for West of GMT, etc).
    if (ApiStatus != NO_ERROR) {
        (VOID) printf(
                "ReplGetTimeCacheValue FAILED, status " FORMAT_API_STATUS ".\n",
                ApiStatus );
        goto Cleanup;
    }
    if (Verbose) {
        (VOID) printf(
                "Master time zone offset (seconds) is " FORMAT_LONG ".\n",
                MasterTimeZoneOffsetSecs );
    }
    assert( MasterTimeZoneOffsetSecs != -1 );

    //
    // Checksum the file or directory.
    //
    if (DoingFiles) {

        ShowFileTimes( Source );
        FakeFindData(
                Source,    // file name
                Verbose,
                &FindData );

        Record.checksum = SingleChecksum(
                MasterTimeZoneOffsetSecs, // exporter offset from GMT
                &FindData );
        Record.count = 1;

    } else {
        ScanTree(
                MasterTimeZoneOffsetSecs, // exporter offset from GMT
                Source,                // dir name  (and scratch space!)
                &Record );
    }

    (VOID) printf( "checksum for '" FORMAT_LPTSTR "' is:\n",
            Source );
    DumpChecksum( &Record );
    ApiStatus = NO_ERROR;


Cleanup:

    // BUGBUG: memory leaks, but who cares?
    if (ApiStatus == NO_ERROR) {
        return (EXIT_SUCCESS);
    } else {
        return (EXIT_FAILURE);
    }

} // main