void PruneGraphOpCommand::execute(void)
{
    std::string sMethod(MainApplication::the()->getSettings().get<std::string>("player.debugger.prune_graph_op.method")),
        sSize(MainApplication::the()->getSettings().get<std::string>("player.debugger.prune_graph_op.size"));

    OSG::PruneGraphOpRefPtr TheGraphOp = OSG::PruneGraphOp::create();

    std::string params = std::string("size=") + sSize + std::string(" method=")  + sMethod;
    TheGraphOp->setParams(params);

    TheGraphOp->traverse(_RootNode);

}
void C4DownloadDlg::OnIdle()
{
	// continue query process
	if (!HTTPClient.Execute())
	{
		// query aborted
		Close(false);
		return;
	}
	if (!HTTPClient.isBusy())
	{
		// download done or aborted
		Close(HTTPClient.isSuccess());
		return;
	}
	StdStrBuf sStatus; int32_t iProgress = -1;
	StdStrBuf sSize("");
	// download in progress: Update status
	if (!HTTPClient.isConnected())
	{
		// still connecting
		sStatus.Ref(LoadResStr("IDS_DL_STATUSCONNECTING"));
	}
	else
	{
		// header received?
		size_t iSize = HTTPClient.getTotalSize();
		if (!iSize)
		{
			// file size unknown: No header received.
			sStatus.Ref(LoadResStr("IDS_PRC_CONNECTED"));
		}
		else
		{
			// file size known: Download in progress
			sStatus.Ref(LoadResStr("IDS_CTL_DL_PROGRESS"));
			if (iSize <= 1024)
				sSize.Format(" (%ld Bytes)", (long)iSize);
			else if (iSize <= 1024*1024)
				sSize.Format(" (%ld KB)", (long)(iSize/1024));
			else
				sSize.Format(" (%ld MB)", (long)(iSize/1024/1024));
			iProgress = int64_t(100) * HTTPClient.getDownloadedSize() / iSize;
		}
	}
	const char *szStatusString = LoadResStr("IDS_PRC_DOWNLOADINGFILE");
	SetStatus(FormatString(szStatusString, GetFilename(HTTPClient.getRequest())).getData(), iProgress );
}
Exemplo n.º 3
0
CString CRemoteFileDialog::FormatSize(DWORD dwSize)
{
	CString sSize(_T("0 KB"));

	if (dwSize > 0 && dwSize < 1024)
	{
		sSize = _T("1 KB");
	}

	else if (dwSize < (1024 * 1024))
	{
		sSize.Format(_T("%d KB"), dwSize / 1024);
	}

	else
	{
		sSize.Format(_T("%.02f MB"), dwSize / (1024.0 * 1024.0));
	}

	return sSize;
}
Exemplo n.º 4
0
/** Compute and Set minimal size for the window
  * Minimal size will be the size with all panes unfolded
  * Override this function if another behaviour is desired
  */
void wxFoldPanelEx::ComputeDimensions(void)
{
    size_t i, iMax;
    wxFoldItemEx *f;
    wxSize sMinSize(0,0);
    wxSize sSize(0,0);

    iMax = GetCount();
    for(i=0;i<iMax;i++)
    {
        f = GetFoldItem(i);
        if (f)
        {
            sSize = f->GetBestSize();
            if (MainSizer) MainSizer->SetItemMinSize(f, sSize.GetWidth(), sSize.GetHeight());
        }
        else
        {
            sSize.SetWidth(0);
            sSize.SetHeight(0);
        }

        if (m_bVertical)
        {
            sMinSize.SetHeight(sMinSize.GetHeight() + sSize.GetHeight());
            if (sSize.GetWidth() > sMinSize.GetWidth()) sMinSize.SetWidth(sSize.GetWidth());
        }
        else
        {
            sMinSize.SetWidth(sMinSize.GetWidth() + sSize.GetWidth());
            if (sSize.GetHeight() > sMinSize.GetHeight()) sMinSize.SetHeight(sSize.GetHeight());
        }
    }

    SetMinSize(sMinSize);
    if (MainSizer) MainSizer->SetMinSize(sMinSize);
}
Exemplo n.º 5
0
void KviMainWindow::setIconSize(unsigned int uSize)
{
	if((uSize != 16) && (uSize != 22) && (uSize != 32) && (uSize != 48))
		uSize = 22;

	KVI_OPTION_UINT(KviOption_uintToolBarIconSize) = uSize;

	QSize sSize(uSize, uSize);

	KviTalMainWindow::setIconSize(sSize);

	KviPointerListIterator<KviMexToolBar> it(*(m_pModuleExtensionToolBarList));
	if(it.current())
	{
		while(KviMexToolBar * t = it.current())
		{
			t->setIconSize(sSize);
			t->update();
			++it;
		}
	}

	KviPointerHashTableIterator<QString, KviCustomToolBarDescriptor> it2(*(KviCustomToolBarManager::instance()->descriptors()));
	if(it2.current())
	{
		while(KviCustomToolBarDescriptor * d = it2.current())
		{
			if(d->toolBar())
			{
				d->toolBar()->setIconSize(sSize);
				d->toolBar()->update();
			}
			++it2;
		}
	}
}
Exemplo n.º 6
0
		bool Module::init(const std::string &strModuleText, int argc, char **argv, bool bStrictParse)
		{
			m_argc = argc;
			m_argv = argv;

			loop = new PortComm(NULL);

			std::string strConfigFile;
			// allocate option on heap (no delete on purpose)
			flowvr::utils::Option<std::string> *portFile =
					new flowvr::utils::Option<std::string>("portfile", 'p', "path to the module parameter file", false);
			flowvr::utils::Option<bool> *dgbWait =
					new flowvr::utils::Option<bool>("dbgWait", 'd', "wait infinite to have a debugger attached", false, true);

			flowvr::utils::Option<bool> *initWait =
					new flowvr::utils::Option<bool>("initWait", 'd', "wait infinite to have a debugger attached (init routine)", false, true);

			flowvr::utils::Option<std::string> *idstring =
					new flowvr::utils::Option<std::string>("idstring", 'i', "id string passed from flowvr-app", true);

			flowvr::utils::Option<std::string> *argtree =
					new flowvr::utils::Option<std::string>("argtree", 'a', "base64 encoded / bzip2 compressed arguments", false);

			flowvr::utils::CmdLine line(std::string(argv[0]) + strModuleText );

			bool bError=false;

			if(line.parse( argc, argv, &bError ) == false and bError == false )
			{
				// help option
				std::cout << line.help() << std::endl;
				return false;
			}

			if((*portFile).count == 0)
			{
				// ok, we can stop here... we NEED a portfile declaration
				if( idstring->count == 0 )
					std::cerr << "no portfile specified. STOP." << std::endl;
				else
					std::cerr << "[" << idstring->value() << "] -- no portfile specified. STOP." << std::endl;
				return false;
			}

			if( (*initWait).value() == true )
			{
				std::cerr << "PortComm::setInifiteWaitFlag() during init for [" << getpid() << "]-- ATTENTION" << std::endl;
				bool b = true;
				while(b)
				{
					flowvr::utils::microsleep(1000);
				}
			}

			// cache value, as the upcoming parsing might reset that it was already written,
			// so we lose the value on the second parsing
			std::string strIdTag = idstring->value();
			std::string argT     = argtree->value();

			std::string pFile( (*portFile).value() );

			if( !descFiles.exists( pFile ) )
			{
				if(!descFiles.findFile( pFile ))
				{
					std::cerr << " ** could not resolve portfile [" << pFile << "]" << std::endl;
					return false;
				}
			}

			flowvr::xml::TiXmlDocument config( pFile.c_str() );
			if( config.LoadFile() )
			{
				// configure plugins first
				flowvr::xml::TiXmlHandle docHandle( &config );

				flowvr::xml::TiXmlHandle configNode  = docHandle.FirstChild("config");
				flowvr::xml::TiXmlHandle xmlServices = configNode.FirstChild("services");

				flowvr::xml::TiXmlHandle ports      = configNode.FirstChild("ports");
				flowvr::xml::TiXmlHandle xmlPlugs   = configNode.FirstChild("plugins");
				flowvr::xml::TiXmlHandle code       = configNode.FirstChild("code");
				flowvr::xml::TiXmlHandle stampsConf = configNode.FirstChild("stamplists");


				std::map<std::string, flowvr::Port*> mpPorts;
				std::vector<flowvr::Port*>           vePorts;

				flowvr::portutils::ARGS argmap;

				std::string::size_type n = argT.find_first_of(':', 0);
				if( !n or n == std::string::npos )
				{
					std::cerr << argtree->count << ": argtree given, but no size prefix!" << std::endl
							  << "argtree = " << argtree->value() << std::endl;
					argmap["services"] = flowvr::portutils::Parameter( flowvr::portutils::ParameterContainer() );
					argmap["plugins"]  = flowvr::portutils::Parameter( flowvr::portutils::ParameterContainer() );
					argmap["module"]   = flowvr::portutils::Parameter( flowvr::portutils::ParameterContainer() );
				}
				else
				{
					std::string sb64( argT.begin()+n+1, argT.end() );
					std::string sSize( argT.begin(), argT.begin()+n);

					flowvr::portutils::ARGS::fromBase64(sb64, argmap, atol(sSize.c_str()) );
				}

				flowvr::portutils::configureServiceLayers( xmlServices, services );

				// create argument listings
				flowvr::portutils::prepareServices( services );
				flowvr::portutils::createServices(services, *this, argmap["services"].getSubContainerConstRef());
				flowvr::portutils::configurePlugins(xmlPlugs, services, plugs, argmap["plugins"].getSubContainerConstRef() );

				// load the stamp list for this configuration.
				// the stamp list is expected to reside in the very same directory
				// as the portfile itself, so we look for the prefix in the path given
				// for the portfile.
				std::string strPrefix;
				std::string::size_type np = pFile.find_last_of("/"); // is it like: /<path>/<path>/
				if( np != std::string::npos )
				{
					// yes... prefixed with a relative or absolute path
					strPrefix = pFile.substr(0,np+1); // include slash
				} // else: no, its probably in the same directory, so prefix will be empty.

				flowvr::portutils::configureStampMap( stampsConf, stampMap, "", strPrefix );

				flowvr::portutils::configurePorts( ports, stampMap, mpPorts, vePorts, argmap["module"].getSubContainerConstRef() );
				flowvr::portutils::configurePortComm( code, mpPortComms, mpPorts, plugs );

				flowvr =  flowvr::initModule( vePorts );
			}
			else
			{
				std::cerr << "could not load port-config file given as [" << pFile << "]" << std::endl;
				const char *pcErr = config.ErrorDesc();
				if(pcErr)
					std::cerr << "row: " << config.ErrorRow() << std::endl
							  << "col: " << config.ErrorCol() << std::endl
							  << "err: " << pcErr << std::endl;
				return false;
			}

			if((*dgbWait).value())
				(*loop).setInfiniteWaitFlag();

			std::vector<IServiceLayer*> v;

			for(SERV::const_iterator cit = services.begin(); cit != services.end(); ++cit )
			{
				if( (*cit).second.m_layer )
					v.push_back( (*cit).second.m_layer );
			}

			(*loop).setServices(v);

			(*loop).setCodeRange( mpPortComms );

			(*loop).setModuleAPI(flowvr);
			(*loop).setDefaultReturn(flowvr::portutils::PortComm::RET_FAIL);

			if( flowvr )
			{
				std::for_each( v.begin(), v.end(), std::mem_fun( &flowvr::portutils::IServiceLayer::Once ) );

				for( std::vector<PortComm::PortMap>::iterator it = mpPortComms.begin(); it != mpPortComms.end(); ++it )
					(*it).once(flowvr);
			}

			return true;
		}
Exemplo n.º 7
0
ret_ CXMLLoaderActions::LoadDataBlock(CData &Data,
									  const DOMElement *pElement)
{
#ifdef _DEBUG_
	if (!pElement)
		return PARAMETER_NULL | PARAMETER_2;
#endif

	DOMElement *pChild = (DOMElement *)pElement->getFirstChild();

	if (!pChild)
		return XML_LOADER_ERROR;

	auto_xerces_str	wsObject	("v_object");
	auto_xerces_str wsB1		("v_b_1");
	auto_xerces_str wsUB1		("v_ub_1");
	auto_xerces_str wsB2		("v_b_2");
	auto_xerces_str wsUB2		("v_ub_2");
	auto_xerces_str wsB4		("v_b_4");
	auto_xerces_str wsUB4		("v_ub_4");
	auto_xerces_str wsB8		("v_b_8");
	auto_xerces_str wsUB8		("v_ub_8");
	auto_xerces_str wsFB4		("v_fb_4");
	auto_xerces_str wsFB8		("v_fb_8");
	auto_xerces_str	wsString	("v_string");
	auto_xerces_str wsGroup		("v_group");

	auto_xerces_str	wsName		("name");
	auto_xerces_str	wsValue		("value");

	while (pChild)
	{
		if (0 == XMLString::compareString(pChild->getNodeName(), wsObject))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (false_v == Data.Define(sName, (obj_)null_v))
				return XML_LOADER_ERROR;
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsB1))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, B_1))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, B_1, (b_4)atoi(sValue)))
					return XML_LOADER_ERROR;
			}

		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsUB1))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, UB_1))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, UB_1, (b_4)atoi(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsB2))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, B_2))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, B_2, (b_4)atoi(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsUB2))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, UB_2))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, UB_2, (b_4)atoi(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsB4))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, B_4))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, B_4, (b_4)atoi(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsUB4))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, UB_4))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, UB_4, (b_4)atoi(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsB8))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, B_8))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, B_8, (b_8)atoll(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsUB8))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, UB_8))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, UB_8, (ub_8)atoll(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsFB4))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, FB_4))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, (fb_4)atof(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsFB8))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, FB_8))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, (fb_8)atof(sValue)))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsString))
		{
			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sValue	(pChild->getAttribute(wsValue));

			if (0 == strcmp(sValue, SIGN_UNBOUNDED))
			{
				if (false_v == Data.Define(sName, (ch_1 *)""))
					return XML_LOADER_ERROR;
			}
			else
			{
				if (false_v == Data.Define(sName, sValue))
					return XML_LOADER_ERROR;
			}
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(), wsGroup))
		{
			auto_xerces_str wsNormal("normal");
			auto_xerces_str wsFloat	("float");
			auto_xerces_str wsString("string");

			auto_xerces_str	wsName	("name");
			auto_xerces_str	wsLength("length");
			auto_xerces_str	wsSigned("signed");
			auto_xerces_str	wsSize	("size");

			auto_xerces_str sName	(pChild->getAttribute(wsName));
			auto_xerces_str sSize	(pChild->getAttribute(wsSize));

			CFieldGroupDefined *pGroupField = new CFieldGroupDefined(
				sName, 
				sSize);

			DOMElement *pSub = (DOMElement *)pChild->getFirstChild();

			if (!pSub)
				return XML_LOADER_ERROR;

			while (pSub)
			{
				if (0 == XMLString::compareString(pSub->getNodeName(),
												  wsNormal))
				{
					auto_xerces_str sName (pElement->getAttribute(wsName));
					auto_xerces_str	sLength(pElement->getAttribute(wsLength));
					auto_xerces_str	sSigned(pElement->getAttribute(wsSigned));

					EFieldType Type;

					GetFieldType(
						FIELD_NORMAL_STYLE, 
						atoi(sLength), 
						0 == strcmp(sSigned, "true") ? true_v : false_v,
						Type);
					
					CFieldNumber *pField = new CFieldNumber(sName, 
															Type, 
															pGroupField);

					pGroupField->SetSubField(pField);
				}
				else if (0 == XMLString::compareString(pSub->getNodeName(),
													   wsFloat))
				{
					auto_xerces_str sName (pElement->getAttribute(wsName));
					auto_xerces_str	sLength(pElement->getAttribute(wsLength));

					EFieldType Type;

					GetFieldType(FIELD_FLOAT_STYLE, 
								 atoi(sLength), 
								 false_v, 
								 Type);
					
					CFieldNumber *pField = new CFieldNumber(sName, 
															Type, 
															pGroupField);

					pGroupField->SetSubField(pField);
				}
				else if (0 == XMLString::compareString(pSub->getNodeName(),
													   wsString))
				{
					auto_xerces_str sName (pElement->getAttribute(wsName));
					auto_xerces_str	sLength(pElement->getAttribute(wsLength));
					auto_xerces_str	sSize(pElement->getAttribute(wsSize));
					
					CFieldString *pField = new CFieldString(sName, 
															atoi(sSize), 
															pGroupField);

					pGroupField->SetSubField(pField);
				}

				pSub = (DOMElement *)pSub->getNextSibling();
			}
			
			if (false_v == Data.Define(pGroupField))
				return XML_LOADER_ERROR;
		}

		pChild = (DOMElement *)pChild->getNextSibling();
	}

	return SUCCESS;
}