void LLGridManager::setGridChoice(const std::string& grid)
{
	// Set the grid choice based on a string.
	// The string can be:
	// - a grid label from the gGridInfo table 
	// - a hostname
	// - an ip address

	// loop through.  We could do just a hash lookup but we also want to match
	// on label
	std::string grid_name = grid;
	if(!mGridList.has(grid_name))
	{
		// case insensitive
		grid_name = getGridByLabel(grid);
	}
	
	if(grid_name.empty())
	{
		// the grid was not in the list of grids.
		LLSD grid_data = LLSD::emptyMap();
		grid_data[GRID_VALUE] = grid;
		addGrid(grid_data);		
	}
	mGrid = grid;
	gSavedSettings.setString("CurrentGrid", grid);

	updateIsInProductionGrid();
}
Example #2
0
// get location slurl base for the given region 
// within the selected grid (LL comment was misleading)
std::string LLGridManager::getSLURLBase(const std::string& grid)
{
	std::string grid_base;
	std::string ret;
	if(mGridList.has(grid) && mGridList[grid].has(GRID_SLURL_BASE))
	{
		ret = mGridList[grid][GRID_SLURL_BASE].asString();
		LL_DEBUGS("GridManager") << "GRID_SLURL_BASE: " << ret << LL_ENDL;// <AW opensim>
	}
//<AW opensim>
	else
	{
		LL_DEBUGS("GridManager") << "Trying to fetch info for:" << grid << LL_ENDL;
		GridEntry* grid_entry = new GridEntry;
		grid_entry->set_current = false;
		grid_entry->grid = LLSD::emptyMap();	
		grid_entry->grid[GRID_VALUE] = grid;

		// add the grid with the additional values, or update the
		// existing grid if it exists with the given values
		addGrid(grid_entry, FETCHTEMP);
// </AW opensim>
		ret = llformat(DEFAULT_HOP_BASE, grid.c_str());// <AW: hop:// protocol>
		LL_DEBUGS("GridManager") << "DEFAULT_HOP_BASE: " << ret  << LL_ENDL;// <AW opensim>
	}

	return  ret;
}
Example #3
0
/// overload the constructor with some external sigmas: needed for histogram
BiasRepresentation::BiasRepresentation(vector<Value*> tmpvalues, Communicator &cc , vector<string> gmin, vector<string> gmax, vector<unsigned> nbin , vector<double> sigma):hasgrid(false), rescaledToBias(false),histosigma(sigma),mycomm(cc){
    ndim=tmpvalues.size();
    for(int  i=0;i<ndim;i++){
         values.push_back(tmpvalues[i]);
         names.push_back(values[i]->getName());
    }
    // initialize the grid 
    addGrid(gmin,gmax,nbin);
}
Example #4
0
void LLGridManager::setGridChoice(const std::string& grid)
{
	if(grid.empty()) return;

	// Set the grid choice based on a string.
	// The string can be:
	// - a grid label from the gGridInfo table 
	// - a hostname
	// - an ip address

	// loop through.  We could do just a hash lookup but we also want to match
	// on label

	mReadyToLogin = false;
	std::string grid_name = grid;
	if(mGridList.has(grid_name))
	{
		LL_DEBUGS("GridManager")<< "got grid from grid list: " << grid << LL_ENDL;
	}
	else
	{
		// case insensitive
		grid_name = getGridByLabel(grid);
		if (!grid_name.empty())
			LL_DEBUGS("GridManager")<< "got grid by label: " << grid << LL_ENDL;
	}



	if(grid_name.empty())
	{
		// case insensitive
		grid_name = getGridByGridNick(grid);
		if (!grid_name.empty())
			LL_DEBUGS("GridManager")<< "got grid by gridnick: " << grid << LL_ENDL;
	}
	
	if(grid_name.empty())
	{
		LL_DEBUGS("GridManager")<< "trying to fetch grid: " << grid << LL_ENDL;
		// the grid was not in the list of grids.
		GridEntry* grid_entry = new GridEntry;
		grid_entry->grid = LLSD::emptyMap();
		grid_entry->grid[GRID_VALUE] = grid;
		grid_entry->set_current = true;
		addGrid(grid_entry, FETCH);
	}
	else
	{
		LL_DEBUGS("GridManager")<< "setting grid choice: " << grid << LL_ENDL;
		mGrid = grid;
		gSavedSettings.setString("CurrentGrid", grid); 
		updateIsInProductionGrid();
		mReadyToLogin = true;
	}
}
Example #5
0
void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer)
{
	if (mergeIfNewer) {
		LLSD::array_const_iterator it, end = gridInfo.endArray();
		for (it = gridInfo.beginArray(); it != end; ++it) {
			LLSD gridMap = *it;
			if (gridMap.has("default_grids_version")) {
				int version = gridMap["default_grids_version"];
				if (version <= mDefaultGridsVersion) return;
				else break;
			}
		}
		if (it == end) {
			llwarns << "Grid data has no version number." << llendl;
			return;
		}
	}

	llinfos << "Loading grid data." << llendl;

	LLSD::array_const_iterator it, end = gridInfo.endArray();
	for (it = gridInfo.beginArray(); it != end; ++it) {
		LLSD gridMap = *it;
		if (gridMap.has("default_grids_version")) {
			mDefaultGridsVersion = gridMap["default_grids_version"];
		} else if (gridMap.has("gridnick") && gridMap.has("loginuri")) {
			std::string gridnick = gridMap["gridnick"];
			HippoGridInfo *grid;
			GridIterator it = mGridInfo.find(gridnick);
			bool newGrid = (it == mGridInfo.end());
			if (newGrid) {
				// create new grid info
				grid = new HippoGridInfo(gridnick);
			} else {
				// update existing grid info
				grid = it->second;
			}
			grid->setLoginUri(gridMap["loginuri"]);
			if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]);
			if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]);
			if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]);
			if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]);
			if (gridMap.has("website")) grid->setWebSite(gridMap["website"]);
			if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]);
			if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]);
			if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]);
			//if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]);
			if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]);
			if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]);
			if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]);
			if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]);
			if (newGrid) addGrid(grid);
		}
	}
}
Example #6
0
/// Adjusts the underlying grid based on the graphs that are displayed in the diagram
void DiagramScene::constructGrid()
{
	// be very careful with scaling parameters here!
	int numXTicks, numYTicks;
	float xMin = _unscaledBounds.left();
	float yMin = _unscaledBounds.top();
	float xMax = _unscaledBounds.right();
	float yMax = _unscaledBounds.bottom();

	adjustAxis(xMin, xMax, numXTicks);
	adjustAxis(yMin, yMax, numYTicks);

	// adjust boundaries of coordinate system according to scaling
	_bounds.setRect(    xMin * _scaleX,
	                    yMin * _scaleY,
	                    (xMax - xMin) * _scaleX,
	                    (yMax - yMin) * _scaleY
	                    );

	QPen pen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin);
	_grid = addGrid(_bounds, numXTicks, numYTicks, pen);

	if (_startDate == QDateTime())
	{
		for (int i = 0; i <= numXTicks; ++i)
		{
			int x = static_cast<int>(_bounds.left() / _scaleX +
									 (i * (_bounds.width() / _scaleX) / numXTicks));
			_xTicksText.push_back(addNonScalableText(QString::number(x)));
			_xTicksText.last()->setPos(x * _scaleX, _bounds.bottom() + 15);
		}
	}
	else
	{
		for (int i = 0; i <= numXTicks; ++i)
		{
			int x = static_cast<int>(_bounds.left() / _scaleX +
									 (i * (_bounds.width() / _scaleX) / numXTicks));
			QDateTime currentDate = _startDate.addSecs(x);
			_xTicksText.push_back(addNonScalableText(currentDate.toString("dd.MM.yyyy")));
			_xTicksText.last()->setPos(x * _scaleX, _bounds.bottom() + 15);
		}
	}

	for (int j = 0; j <= numYTicks; ++j)
	{
		float y     = _bounds.bottom() / _scaleY -
		              (j * (_bounds.height() / _scaleY) / numYTicks);
		float label = _bounds.top()   / _scaleY +
		              (j * (_bounds.height() / _scaleY) / numYTicks);
		_yTicksText.push_back(addNonScalableText(QString::number(label)));
		_yTicksText.last()->setPos(_bounds.left() - MARGIN / 2, y * _scaleY);
	}
}
GridSceneCombinationLock::GridSceneCombinationLock(QObject* parent, InternalInterface::CrosswordStateToGridScene* const crosswordState) : GridScene3D(parent, crosswordState)
{
    m_TypingDirection = CLOCKWISE;

    auto numGrids = getCrosswordInterface()->getGrid().m_Dimensions.z();

    for(int z = 0; z < numGrids; z++)
    {
        addGrid(z);
    }
}
        void Render::fillBuffers()
        {
            addGrid();
            addContainer();

            Model::Cube cube = Model::Cube();
            std::vector <glm::vec3> cubeVertices = cube.getVertices();
            std::vector <glm::vec3> cubeNormals = cube.getNormals();

            vertices.insert(vertices.end(), cubeVertices.begin(), cubeVertices.end());
            normals.insert(normals.end(), cubeNormals.begin(), cubeNormals.end());
        }
/// overload the constructor: add the grid at constructor time 
BiasRepresentation::BiasRepresentation(vector<Value*> tmpvalues, Communicator &cc , vector<string> gmin, vector<string> gmax, 
                                       vector<unsigned> nbin, bool doInt, double lowI, double uppI ):hasgrid(false), rescaledToBias(false), mycomm(cc), BiasGrid_(NULL){
    ndim=tmpvalues.size();
    for(int  i=0;i<ndim;i++){
         values.push_back(tmpvalues[i]);
         names.push_back(values[i]->getName());
    }
    doInt_=doInt;
    lowI_=lowI;
    uppI_=uppI;
    // initialize the grid 
    addGrid(gmin,gmax,nbin);
} 
Example #10
0
void
AnimatorScene::setGridLinesCount (int nGridLines)
{
  m_nGridLines = nGridLines;
  bool showGrid = m_showGrid;
  resetGrid ();
  m_showGrid = showGrid;
  if (m_showGrid)
    {
      addGrid ();
    }
  update ();
}
bool
FixPaintSelection::setGridValue(const Point& pt, const TextureGridInfo& info)
{
    GridMap::iterator it;

    if(!existGrid(pt))
        it = addGrid(pt);
    else
        it = mGrids.find(pt);

    it->second.info = info;
    return true;
}
bool
FixPaintSelection::setFlagValue(const Point& pt,unsigned int flags)
{
    GridMap::iterator it;

    if(!existGrid(pt))
        it = addGrid(pt);
    else
        it = mGrids.find(pt);

    it->second.flags = flags;
    return true;
}
Example #13
0
void BccLattice::add38Node(const Vector3F & center, float h)
{
	const unsigned ccenter = mortonEncode(center);
	unsigned cgreen, cgreen1;
	Vector3F corner, corner1;
    int i;
    float hh = h * .5f;
	for(i=0; i < 8; i++) {
        corner = center + Vector3F(hh * OctChildOffset[i][0], 
        hh * OctChildOffset[i][1], 
        hh * OctChildOffset[i][2]);
        
        addGrid(corner);
    }
    for(i=0; i < 6; i++) {
        corner = center + Vector3F(h * HexHeighborOffset[i][0], 
        h * HexHeighborOffset[i][1], 
        h * HexHeighborOffset[i][2]);
        
        cgreen = addGrid(corner);
        m_greenEdges->addEdge(ccenter, cgreen);
    }
    for(i=0; i < 24; i++) {
        corner = center + Vector3F(h * ParallelEdgeOffset[i][0][0], 
        h * ParallelEdgeOffset[i][0][1], 
        h * ParallelEdgeOffset[i][0][2]);
        
        cgreen = addGrid(corner);
        
        corner1 = center + Vector3F(h * ParallelEdgeOffset[i][1][0], 
        h * ParallelEdgeOffset[i][1][1], 
        h * ParallelEdgeOffset[i][1][2]);
        
        cgreen1 = addGrid(corner1);
        
        m_greenEdges->addEdge(cgreen, cgreen1);
    }
    addGrid(center);
}
Example #14
0
void LLGridManager::initGridList(std::string grid_file, AddState state)
{
	LLSD other_grids;
	llifstream llsd_xml;
	if (grid_file.empty())
	{
		return;
	}

	if(!gDirUtilp->fileExists(grid_file))
	{
		return;
	}

	llsd_xml.open( grid_file.c_str(), std::ios::in | std::ios::binary );

	// parse through the gridfile
	if( llsd_xml.is_open()) 
	{
		LLSDSerialize::fromXMLDocument( other_grids, llsd_xml );
		if(other_grids.isMap())
		{
			for(LLSD::map_iterator grid_itr = other_grids.beginMap(); 
				grid_itr != other_grids.endMap();
				++grid_itr)
			{
				LLSD::String key_name = grid_itr->first;
				GridEntry* grid_entry = new GridEntry;
				grid_entry->set_current = false;
				grid_entry->grid = grid_itr->second;

				LL_DEBUGS("GridManager") << "reading: " << key_name << LL_ENDL;

				try
				{
					addGrid(grid_entry, state);
					LL_DEBUGS("GridManager") << "Added grid: " << key_name << LL_ENDL;
				}
				catch (...)
				{
				}

			}
			llsd_xml.close();
		}
	}

}
Example #15
0
void CreaTexts()
{

 //Step1
 hwT0 = addLabel("Copy/paste script source here,  or open a js/html file", 10,50,WINW3,30);
 hwSrcEdit = addMLEdit(ID_SRCEDIT,10, 80, WINW2, 450);
 hwTp0 = addLabel("", 400,50,100,30);

 //Step2
 hwT1 = addLabel("Set options for javascript minifier:", 10,50,WINW3,30);
 hwM0 = addCheckBox("remove redundant spaces and tabs", 10,90,WINW3,30, TRUE);
 hwM1 = addCheckBox("reduce linebreaks", 10,120,WINW3,30, TRUE);
 hwM2 = addCheckBox("remove comments", 10,150,WINW3,30, TRUE);
 hwM3 = addCheckBox("some other", 10,180,WINW3,30, TRUE);
 BtMinfy  = addButton(ID_MINFY, "Minify", 10,220,100,30);

 //Step3
 hwT2 = addLabel("Minified result:", 10,50,WINW3,30);
 hwMResEdit = addMLEdit(ID_MRESEDIT,10, 80, WINW2, 450);
 hwTp1 = addLabel("", 400,50,100,30);

 //Step4
 hwT3 = addLabel("Set options for javascript obfuscator:", 10,50,WINW3,30);
 hwO0 = addCheckBox("functions", 10,90,WINW3,30, TRUE);
 hwO1 = addCheckBox("variables", 10,120,WINW3,30, TRUE);
 hwTa = addLabel("minimal length of keywords", 56,164,WINW3,30);
 hwO2 = addCheckBox("also in html", 10,200,WINW3,30, FALSE);
 hwO3 = addCheckBox("all keywords", 10,230,WINW3,30, FALSE);
 hwOLen = addInputField("3", 10,160,40, FontSize+8  );
 BtPrepKw  = addButton(ID_PREOKW, "Prepare keywords", 10,270,180,30);
 
 //Step5
 hwT4 = addLabel("Clear/edit the \"new\" generated name, then obfuscate.", 10,50,WINW3,30);
 hwTb = addLabel("", 400,50,WINW3,100);
 hwKwGrid = addGrid(ID_KWDGRID,10, 100, WINW2, 450);
 CreateColumn(hwKwGrid,0,"new", 50);
 CreateColumn(hwKwGrid,1,"keyword", 220);
 CreateColumn(hwKwGrid,2,"cnt", 60);
 CreateColumn(hwKwGrid,3,"description", 430);
 BtObfsc  = addButton(ID_OBFSC, "Obfuscate", 600,50,140,30);
 
 //Step6
 hwT5 = addLabel("Obfuscated result:", 10,50,WINW3,30);
 hwOResEdit = addMLEdit(ID_ORESEDIT,10, 80, WINW2, 450);
 hwTp2 = addLabel("", 400,50,100,30);
  
 PostMessage(hwnd, WM_NOTIFY, 0, 0);        // display and hide
}
void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer)
{
	LLSD::array_const_iterator it, end = gridInfo.endArray();
	for (it = gridInfo.beginArray(); it != end; ++it) {
		LLSD gridMap = *it;
		if (gridMap.has("gridnick") && gridMap.has("loginuri")) {
			std::string gridnick = gridMap["gridnick"];
			HippoGridInfo *grid;
			GridIterator it = mGridInfo.find(gridnick);
			bool newGrid = (it == mGridInfo.end());
			if (gridMap.has("version")) {
				int version = gridMap["version"];
				if (version == -1) {
					// delete grid
					if (!newGrid) mGridInfo.erase(it);
					continue;
				} else if (mergeIfNewer && !newGrid && (version <= it->second->getVersion())) {
					// don't update if version is not newer
					continue;
				}
			}
			if (newGrid) {
				// create new grid info
				grid = new HippoGridInfo(gridnick);
			} else {
				// update existing grid info
				grid = it->second;
			}
			grid->setLoginUri(gridMap["loginuri"]);
			if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]);
			if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]);
			if (gridMap.has("lastlogin_fname")) grid->setLastFName(gridMap["lastlogin_fname"]);
			if (gridMap.has("lastlogin_lname")) grid->setLastLName(gridMap["lastlogin_lname"]);
			if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]);
			if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]);
			if (gridMap.has("website")) grid->setWebSite(gridMap["website"]);
			if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]);
			if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]);
			if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]);
			//if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]);
			if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]);
			if (gridMap.has("version")) grid->setVersion(gridMap["version"]);
			if (newGrid) addGrid(grid);
		}
	}
}
//
// LLGridManager::addSystemGrid - helper for adding a system grid.
void LLGridManager::addSystemGrid(const std::string& label, 
								  const std::string& name, 
								  const std::string& login, 
								  const std::string& helper,
								  const std::string& login_page,
								  const std::string& login_id)
{
	LLSD grid = LLSD::emptyMap();
	grid[GRID_VALUE] = name;
	grid[GRID_LABEL_VALUE] = label;
	grid[GRID_HELPER_URI_VALUE] = helper;
	grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
	grid[GRID_LOGIN_URI_VALUE].append(login);
	grid[GRID_LOGIN_PAGE_VALUE] = login_page;
	grid[GRID_IS_SYSTEM_GRID_VALUE] = TRUE;
	grid[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray();
	grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT);
	
	grid[GRID_APP_SLURL_BASE] = SYSTEM_GRID_APP_SLURL_BASE;
	if (login_id.empty())
	{
		grid[GRID_ID_VALUE] = name;
	}
	else
	{
		grid[GRID_ID_VALUE] = login_id;
	}
	
	// only add the system grids beyond agni to the visible list
	// if we're building a debug version.
	if (name == std::string(MAINGRID))
	{
		grid[GRID_SLURL_BASE] = MAIN_GRID_SLURL_BASE;		
		grid[GRID_IS_FAVORITE_VALUE] = TRUE;		
	}
	else
	{
		grid[GRID_SLURL_BASE] = llformat(SYSTEM_GRID_SLURL_BASE, label.c_str());
	}
	addGrid(grid);
}
//
// LLGridManager::addSystemGrid - helper for adding a system grid.
void LLGridManager::addSystemGrid(const std::string& label,
								  const std::string& name,
								  const std::string& login_uri,
								  const std::string& helper,
								  const std::string& login_page,
								  const std::string& login_id)
{
	LLSD grid = LLSD::emptyMap();
	grid[GRID_VALUE] = name;
	grid[GRID_LABEL_VALUE] = label;
	grid[GRID_HELPER_URI_VALUE] = helper;
	grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
	grid[GRID_LOGIN_URI_VALUE].append(login_uri);
	grid[GRID_LOGIN_PAGE_VALUE] = login_page;
	grid[GRID_IS_SYSTEM_GRID_VALUE] = true;
	grid[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray();
	grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT);

	grid[GRID_APP_SLURL_BASE] = SYSTEM_GRID_APP_SLURL_BASE;
	if (login_id.empty())
	{
		grid[GRID_ID_VALUE] = name;
	}
	else
	{
		grid[GRID_ID_VALUE] = login_id;
	}

	if (name == std::string(MAINGRID))
	{
		grid[GRID_SLURL_BASE] = MAIN_GRID_SLURL_BASE;
	}
	else
	{
		grid[GRID_SLURL_BASE] = llformat(SYSTEM_GRID_SLURL_BASE, grid[GRID_ID_VALUE].asString().c_str());
	}

	addGrid(grid);
}
Example #19
0
/* gAdjust:
 */
static void
gAdjust (Agraph_t* g, double temp, bport_t* pp, Grid* grid)
{
  Agnode_t*    n;
  Agedge_t*    e;

  if (temp <= 0.0) return;

  clearGrid (grid);

  for (n = agfstnode(g); n; n = agnxtnode(g,n)) {
    DISP(n)[0] = DISP(n)[1] = 0;
    addGrid (grid, floor(n->u.pos[0]/Cell), floor(n->u.pos[1]/Cell), n);
  }

  for (n = agfstnode(g); n; n = agnxtnode(g,n)) {
    for (e = agfstout(g,n); e; e = agnxtout(g,e))
      if (n != e->head) applyAttr (n, e->head, e);
  }
  walkGrid (grid, gridRepulse);


  updatePos (g, temp, pp);
}
Example #20
0
void ParticlesGame::initialize()
{
    // Display the gameplay splash screen
    displayScreen(this, &ParticlesGame::drawSplash, NULL, 250L);

    setMultiTouch(true);

    // Set keyboard state.
    _wDown = _aDown = _sDown = _dDown = false;
    _touched = false;
    _prevX = _prevY = 0;

    // Create a scene with a camera node.
    // The camera node is a child of a node at the same location as the particle emitter.
    // The camera node is offset from its parent, looking straight at it.
    // That way, when we rotate the parent node, the camera stays aimed at the particle emitter.
    _scene = Scene::create();
    Node* cameraNode = _scene->addNode("Camera");
    _cameraParent = _scene->addNode("CameraParent");
    _cameraParent->addChild(cameraNode);
    Camera* camera = Camera::createPerspective(45.0f, (float)getWidth() / (float)getHeight(), 0.25f, 1000.0f);
    cameraNode->setCamera(camera);
    cameraNode->setTranslation(0.0f, 0.0f, ZOOM_DEFAULT);
    _scene->setActiveCamera(camera);
    SAFE_RELEASE(camera);

    addGrid(61);

    // Create a font for drawing the framerate.
    _font = Font::create("res/ui/arial.gpb");

    // Load the form for editing ParticleEmitters.
    _form = Form::create("res/editor.form");
    _form->setConsumeInputEvents(false);
    //_form->setState(Control::FOCUS);

    // Store pointers to UI controls we care about.
    _startRed = (Slider*)_form->getControl("startRed");
    _startGreen = (Slider*)_form->getControl("startGreen");
    _startBlue = (Slider*)_form->getControl("startBlue");
    _startAlpha = (Slider*)_form->getControl("startAlpha");
    _endRed = (Slider*)_form->getControl("endRed");
    _endGreen = (Slider*)_form->getControl("endGreen");
    _endBlue = (Slider*)_form->getControl("endBlue");
    _endAlpha = (Slider*)_form->getControl("endAlpha");
    _particleProperties = (Container*)_form->getControl("particleProperties");
    _startMin = (Slider*)_form->getControl("startMin");
    _startMax = (Slider*)_form->getControl("startMax");
    _endMin = (Slider*)_form->getControl("endMin");
    _endMax = (Slider*)_form->getControl("endMax");
    _energyMin = (Slider*)_form->getControl("energyMin");
    _energyMax = (Slider*)_form->getControl("energyMax");
    _emissionRate = (Slider*)_form->getControl("emissionRate");
    _started = (CheckBox*)_form->getControl("started");
    _reset = (Button*)_form->getControl("reset");
    _emit = (Button*)_form->getControl("emit");
    _zoomIn = (Button*)_form->getControl("zoomIn");
    _zoomOut = (Button*)_form->getControl("zoomOut");
    _save = (Button*)_form->getControl("save");
    _load = (Button*)_form->getControl("load");
    _burstSize = (Slider*)_form->getControl("burstSize");
    _posVarX = (Slider*)_form->getControl("posVarX");
    _posVarY = (Slider*)_form->getControl("posVarY");
    _posVarZ = (Slider*)_form->getControl("posVarZ");
    _velX = (Slider*)_form->getControl("velocityX");
    _velY = (Slider*)_form->getControl("velocityY");
    _velZ = (Slider*)_form->getControl("velocityZ");
    _velVarX = (Slider*)_form->getControl("velocityVarX");
    _velVarY = (Slider*)_form->getControl("velocityVarY");
    _velVarZ = (Slider*)_form->getControl("velocityVarZ");
    _accelX = (Slider*)_form->getControl("accelX");
    _accelY = (Slider*)_form->getControl("accelY");
    _accelZ = (Slider*)_form->getControl("accelZ");
    _accelVarX = (Slider*)_form->getControl("accelVarX");
    _accelVarY = (Slider*)_form->getControl("accelVarY");
    _accelVarZ = (Slider*)_form->getControl("accelVarZ");
    _spinSpeedMin = (Slider*)_form->getControl("spinSpeedMin");
    _spinSpeedMax = (Slider*)_form->getControl("spinSpeedMax");
    _axisX = (Slider*)_form->getControl("axisX");
    _axisY = (Slider*)_form->getControl("axisY");
    _axisZ = (Slider*)_form->getControl("axisZ");
    _axisVarX = (Slider*)_form->getControl("axisVarX");
    _axisVarY = (Slider*)_form->getControl("axisVarY");
    _axisVarZ = (Slider*)_form->getControl("axisVarZ");
    _rotationSpeedMin = (Slider*)_form->getControl("rotationSpeedMin");
    _rotationSpeedMax = (Slider*)_form->getControl("rotationSpeedMax");
    _vsync = (CheckBox*)_form->getControl("vsync");

    // Listen for UI events.
    _startRed->addListener(this, Listener::VALUE_CHANGED);
    _startGreen->addListener(this, Listener::VALUE_CHANGED);
    _startBlue->addListener(this, Listener::VALUE_CHANGED);
    _startAlpha->addListener(this, Listener::VALUE_CHANGED);
    _endRed->addListener(this, Listener::VALUE_CHANGED);
    _endGreen->addListener(this, Listener::VALUE_CHANGED);
    _endBlue->addListener(this, Listener::VALUE_CHANGED);
    _endAlpha->addListener(this, Listener::VALUE_CHANGED);
    _startMin->addListener(this, Listener::VALUE_CHANGED);
    _startMax->addListener(this, Listener::VALUE_CHANGED);
    _endMin->addListener(this, Listener::VALUE_CHANGED);
    _endMax->addListener(this, Listener::VALUE_CHANGED);
    _energyMin->addListener(this, Listener::VALUE_CHANGED);
    _energyMax->addListener(this, Listener::VALUE_CHANGED);
    _emissionRate->addListener(this, Listener::VALUE_CHANGED);
    _started->addListener(this, Listener::VALUE_CHANGED);
    _reset->addListener(this, Listener::CLICK);
    _emit->addListener(this, Listener::CLICK);
    _zoomIn->addListener(this, Listener::PRESS);
    _zoomIn->addListener(this, Listener::RELEASE);
    _zoomOut->addListener(this, Listener::PRESS);
    _zoomOut->addListener(this, Listener::RELEASE);
    _save->addListener(this, Listener::RELEASE);
    _load->addListener(this, Listener::RELEASE);
    _burstSize->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("posX")->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("posY")->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("posZ")->addListener(this, Listener::VALUE_CHANGED);
    _posVarX->addListener(this, Listener::VALUE_CHANGED);
    _posVarY->addListener(this, Listener::VALUE_CHANGED);
    _posVarZ->addListener(this, Listener::VALUE_CHANGED);
    _velX->addListener(this, Listener::VALUE_CHANGED);
    _velY->addListener(this, Listener::VALUE_CHANGED);
    _velZ->addListener(this, Listener::VALUE_CHANGED);
    _velVarX->addListener(this, Listener::VALUE_CHANGED);
    _velVarY->addListener(this, Listener::VALUE_CHANGED);
    _velVarZ->addListener(this, Listener::VALUE_CHANGED);
    _accelX->addListener(this, Listener::VALUE_CHANGED);
    _accelY->addListener(this, Listener::VALUE_CHANGED);
    _accelZ->addListener(this, Listener::VALUE_CHANGED);
    _accelVarX->addListener(this, Listener::VALUE_CHANGED);
    _accelVarY->addListener(this, Listener::VALUE_CHANGED);
    _accelVarZ->addListener(this, Listener::VALUE_CHANGED);
    _spinSpeedMin->addListener(this, Listener::VALUE_CHANGED);
    _spinSpeedMax->addListener(this, Listener::VALUE_CHANGED);
    _axisX->addListener(this, Listener::VALUE_CHANGED);
    _axisY->addListener(this, Listener::VALUE_CHANGED);
    _axisZ->addListener(this, Listener::VALUE_CHANGED);
    _axisVarX->addListener(this, Listener::VALUE_CHANGED);
    _axisVarY->addListener(this, Listener::VALUE_CHANGED);
    _axisVarZ->addListener(this, Listener::VALUE_CHANGED);
    _rotationSpeedMin->addListener(this, Listener::VALUE_CHANGED);
    _rotationSpeedMax->addListener(this, Listener::VALUE_CHANGED);
    _vsync->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("sprite")->addListener(this, Listener::CLICK);
    _form->getControl("additive")->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("transparent")->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("multiply")->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("opaque")->addListener(this, Listener::VALUE_CHANGED);
    _form->getControl("updateFrames")->addListener(this, Listener::CLICK);

    // Load preset emitters.
    loadEmitters();

    updateImageControl();
}
//
// LLGridManager::initialze - initialize the list of known grids based
// on the fixed list of linden grids (fixed for security reasons)
// and the grids.xml file
void LLGridManager::initialize(const std::string& grid_file)
{
	// default grid list.
	// Don't move to a modifiable file for security reasons,
	mGrid.clear() ;

	// set to undefined
	mGridList = LLSD();
	mGridFile = grid_file;
	// as we don't want an attacker to override our grid list
	// to point the default grid to an invalid grid
  	addSystemGrid(SECOND_LIFE_MAIN_LABEL,
				  MAINGRID,
				  MAIN_GRID_LOGIN_URI,
				  "https://secondlife.com/helpers/",
				  DEFAULT_LOGIN_PAGE,
				  "Agni");
	addSystemGrid(SECOND_LIFE_BETA_LABEL,
				  "util.aditi.lindenlab.com",
				  "https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
				  "http://aditi-secondlife.webdev.lindenlab.com/helpers/",
				  DEFAULT_LOGIN_PAGE,
				  "Aditi");

#if 0 //<FS:AW disabled for meeting havok sublicense requirements/>
	LLSD other_grids;
	llifstream llsd_xml;
	if (!grid_file.empty())
	{
		LL_INFOS("GridManager")<<"Grid configuration file '"<<grid_file<<"'"<<LL_ENDL;
		llsd_xml.open( grid_file.c_str(), std::ios::in | std::ios::binary );

		// parse through the gridfile, inserting grids into the list unless
		// they overwrite an existing grid.
		if( llsd_xml.is_open())
		{
			LLSDSerialize::fromXMLDocument( other_grids, llsd_xml );
			if(other_grids.isMap())
			{
				for(LLSD::map_iterator grid_itr = other_grids.beginMap();
					grid_itr != other_grids.endMap();
					++grid_itr)
				{
					LLSD::String key_name = grid_itr->first;
					LLSD grid = grid_itr->second;

					std::string existingGrid = getGrid(grid);
					if (mGridList.has(key_name) || !existingGrid.empty())
					{
						LL_WARNS("GridManager") << "Cannot override existing grid '" << key_name << "'; ignoring definition from '"<<grid_file<<"'" << LL_ENDL;
					}
					else if ( addGrid(grid) )
					{
						LL_INFOS("GridManager") << "added grid '"<<key_name<<"'"<<LL_ENDL;
					}
					else
					{
						LL_WARNS("GridManager") << "failed to add invalid grid '"<<key_name<<"'"<<LL_ENDL;
					}
				}
				llsd_xml.close();
			}
			else
			{
				LL_WARNS("GridManager")<<"Failed to parse grid configuration '"<<grid_file<<"'"<<LL_ENDL;
			}
		}
		else
		{
			LL_WARNS("GridManager")<<"Failed to open grid configuration '"<<grid_file<<"'"<<LL_ENDL;
		}
	}
	else
	{
		LL_DEBUGS("GridManager")<<"no grid file specified"<<LL_ENDL;
	}
#endif //<FS:AW disabled for meeting havok sublicense requirements/>

	// load a grid from the command line.
	// if the actual grid name is specified from the command line,
	// set it as the 'selected' grid.
	std::string cmd_line_grid = gSavedSettings.getString("CmdLineGridChoice");
	if(!cmd_line_grid.empty())
	{
		// try to find the grid assuming the command line parameter is
		// the case-insensitive 'label' of the grid.  ie 'Agni'
		mGrid = getGrid(cmd_line_grid);
		if(mGrid.empty())
		{
			LL_WARNS("GridManager")<<"Unknown grid '"<<cmd_line_grid<<"'"<<LL_ENDL;
		}
		else
		{
			LL_INFOS("GridManager")<<"Command line specified '"<<cmd_line_grid<<"': "<<mGrid<<LL_ENDL;
		}
	}
	else
	{
		// if a grid was not passed in via the command line, grab it from the CurrentGrid setting.
		// if there's no current grid, that's ok as it'll be either set by the value passed
		// in via the login uri if that's specified, or will default to maingrid
		std::string last_grid = gSavedSettings.getString("CurrentGrid");
		if ( ! getGrid(last_grid).empty() )
		{
			LL_INFOS("GridManager")<<"Using last grid: "<<last_grid<<LL_ENDL;
// <FS:AW last grid might be unknown switching between SL/OpenSim flavour>
//			mGrid = last_grid;
			mGrid = getGrid(last_grid);
// </FS:AW last grid might be unknown switching between SL/OpenSim flavour>
		}
		else
		{
			LL_INFOS("GridManager")<<"Last grid '"<<last_grid<<"' not configured"<<LL_ENDL;
		}
	}

	if(mGrid.empty())
	{
		// no grid was specified so default to maingrid
		LL_INFOS("GridManager") << "Default grid to "<<MAINGRID<< LL_ENDL;
		mGrid = MAINGRID;
	}

	LLControlVariablePtr grid_control = gSavedSettings.getControl("CurrentGrid");
	if (grid_control.notNull())
	{
		grid_control->getSignal()->connect(boost::bind(&LLGridManager::updateIsInProductionGrid, this));
	}

	// since above only triggers on changes, trigger the callback manually to initialize state
	updateIsInProductionGrid();

	setGridChoice(mGrid);
}
Example #22
0
void LLGridManager::initCmdLineGrids()
{
	mCommandLineDone = true;

	// load a grid from the command line.
	// if the actual grid name is specified from the command line,
	// set it as the 'selected' grid.
	LLSD cmd_line_login_uri = gSavedSettings.getLLSD("CmdLineLoginURI");
	if (cmd_line_login_uri.isString() && !cmd_line_login_uri.asString().empty())
	{	
		mGrid = cmd_line_login_uri.asString();
		gSavedSettings.setLLSD("CmdLineLoginURI", LLSD::emptyArray());	//in case setGridChoice tries to addGrid 
									//and  addGrid recurses here.
		setGridChoice(mGrid);
		return;
	}

	std::string cmd_line_grid = gSavedSettings.getString("CmdLineGridChoice");
	if(!cmd_line_grid.empty())
	{

		// try to find the grid assuming the command line parameter is
		// the case-insensitive 'label' of the grid.  ie 'Agni'

		mGrid = getGridByGridNick(cmd_line_grid);
		gSavedSettings.setString("CmdLineGridChoice",std::string());

		if(mGrid.empty())
		{
			mGrid = getGridByLabel(cmd_line_grid);

		}
		if(mGrid.empty())
		{
			// if we couldn't find it, assume the
			// requested grid is the actual grid 'name' or index,
			// which would be the dns name of the grid (for non
			// linden hosted grids)
			// If the grid isn't there, that's ok, as it will be
			// automatically added later.
			mGrid = cmd_line_grid;
		}
		
	}

	else
	{
		// if a grid was not passed in via the command line, grab it from the CurrentGrid setting.
		// if there's no current grid, that's ok as it'll be either set by the value passed
		// in via the login uri if that's specified, or will default to maingrid
		mGrid = gSavedSettings.getString("CurrentGrid");
	}
	
	if(mGrid.empty())
	{
		// no grid was specified so default to maingrid
		LL_DEBUGS("GridManager") << "Setting grid to MAINGRID as no grid has been specified " << LL_ENDL;
		mGrid = MAINGRID;
	}
	
	// generate a 'grid list' entry for any command line parameter overrides
	// or setting overides that we'll add to the grid list or override
	// any grid list entries with.

	
	if(mGridList.has(mGrid))
	{
// 		grid_entry->grid = mGridList[mGrid];
		LL_DEBUGS("GridManager") << "Setting commandline grid " << mGrid << LL_ENDL;
		setGridChoice(mGrid);
	}
	else
	{
		LL_DEBUGS("GridManager") << "Trying to fetch commandline grid " << mGrid << LL_ENDL;
		GridEntry* grid_entry = new GridEntry;
		grid_entry->set_current = true;
		grid_entry->grid = LLSD::emptyMap();	
		grid_entry->grid[GRID_VALUE] = mGrid;

		// add the grid with the additional values, or update the
		// existing grid if it exists with the given values
		addGrid(grid_entry, FETCH);
	}
}
//
// LLGridManager::initialze - initialize the list of known grids based
// on the fixed list of linden grids (fixed for security reasons)
// the grids.xml file
// and the command line.
void LLGridManager::initialize(const std::string& grid_file)
{
	// default grid list.
	// Don't move to a modifiable file for security reasons,
	mGrid.clear() ;
	// set to undefined
	mGridList = LLSD();
	// as we don't want an attacker to override our grid list
	// to point the default grid to an invalid grid
	addSystemGrid("None", "", "", "", DEFAULT_LOGIN_PAGE);
	


  	addSystemGrid("Second Life",                                                                                             
				  MAINGRID,                                               
				  "https://login.agni.lindenlab.com/cgi-bin/login.cgi",                    
				  "https://secondlife.com/helpers/",     
				  DEFAULT_LOGIN_PAGE);
	addSystemGrid("Second Life Beta",                                                                                             
				  "util.aditi.lindenlab.com",                                              
				  "https://login.aditi.lindenlab.com/cgi-bin/login.cgi",                   
				  "http://aditi-secondlife.webdev.lindenlab.com/helpers/",
				  DEFAULT_LOGIN_PAGE);

	
	LLSD other_grids;
	llifstream llsd_xml;
	
	// load the systemwide grids file from 
	std::string globalGridFile = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,  "grids.xml");
	LL_INFOS("Grid Manager") << globalGridFile << LL_ENDL;
	if (!globalGridFile.empty())
	{
		llsd_xml.open( globalGridFile.c_str(), std::ios::in | std::ios::binary );

		// parse through the gridfile, inserting grids into the list unless
		// they overwrite a linden grid.
		if( llsd_xml.is_open()) 
		{
			LLSDSerialize::fromXMLDocument( other_grids, llsd_xml );
			if(other_grids.isMap())
			{
				for(LLSD::map_iterator grid_itr = other_grids.beginMap(); 
					grid_itr != other_grids.endMap();
					++grid_itr)
				{
					LLSD::String key_name = grid_itr->first;
					LLSD grid = grid_itr->second;
					// TODO:  Make sure gridfile specified label is not 
					// a system grid label
					LL_DEBUGS("GridManager") << "reading: " << key_name << LL_ENDL;
					if (mGridList.has(key_name) &&
						mGridList[key_name].has(GRID_IS_SYSTEM_GRID_VALUE))
					{
						LL_DEBUGS("GridManager") << "Cannot override grid " << key_name << " as it's a system grid" << LL_ENDL;
						// If the system grid does exist in the grids file, and it's marked as a favorite, set it as a favorite.
						if(grid_itr->second.has(GRID_IS_FAVORITE_VALUE) && grid_itr->second[GRID_IS_FAVORITE_VALUE].asBoolean() )
						{
							mGridList[key_name][GRID_IS_FAVORITE_VALUE] = TRUE;
						}
					}
					else
					{
						try
						{
							addGrid(grid);
							LL_DEBUGS("GridManager") << "Added grid: " << key_name << LL_ENDL;
						}
						catch (...)
						{
						}
					}
				}
				llsd_xml.close();
			}	
		}     
	}
	
	// load the user grid file
	mGridFile = grid_file;
	LL_INFOS("Grid Manager") << mGridFile << LL_ENDL;
	if (!grid_file.empty())
	{
		llsd_xml.open( grid_file.c_str(), std::ios::in | std::ios::binary );

		// parse through the gridfile, inserting grids into the list unless
		// they overwrite a linden grid.
		if( llsd_xml.is_open()) 
		{
			LLSDSerialize::fromXMLDocument( other_grids, llsd_xml );
			if(other_grids.isMap())
			{
				for(LLSD::map_iterator grid_itr = other_grids.beginMap(); 
					grid_itr != other_grids.endMap();
					++grid_itr)
				{
					LLSD::String key_name = grid_itr->first;
					LLSD grid = grid_itr->second;
					// TODO:  Make sure gridfile specified label is not 
					// a system grid label
					LL_DEBUGS("GridManager") << "reading: " << key_name << LL_ENDL;
					if (mGridList.has(key_name) &&
						mGridList[key_name].has(GRID_IS_SYSTEM_GRID_VALUE))
					{
						LL_DEBUGS("GridManager") << "Cannot override grid " << key_name << " as it's a system grid" << LL_ENDL;
						// If the system grid does exist in the grids file, and it's marked as a favorite, set it as a favorite.
						if(grid_itr->second.has(GRID_IS_FAVORITE_VALUE) && grid_itr->second[GRID_IS_FAVORITE_VALUE].asBoolean() )
						{
							mGridList[key_name][GRID_IS_FAVORITE_VALUE] = TRUE;
						}
					}
					else
					{
						try
						{
							addGrid(grid);
							LL_DEBUGS("GridManager") << "Added grid: " << key_name << LL_ENDL;
						}
						catch (...)
						{
						}
					}
				}
				llsd_xml.close();
			}	
		}     
	}
	
	// load a grid from the command line.
	// if the actual grid name is specified from the command line,
	// set it as the 'selected' grid.
	std::string cmd_line_grid = gSavedSettings.getString("CmdLineGridChoice");
	if(!cmd_line_grid.empty())
	{
		// try to find the grid assuming the command line parameter is
		// the case-insensitive 'label' of the grid.  ie 'Agni'
		mGrid = getGridByLabel(cmd_line_grid);
		if(mGrid.empty())
		{
			// if we couldn't find it, assume the
			// requested grid is the actual grid 'name' or index,
			// which would be the dns name of the grid (for non
			// linden hosted grids)
			// If the grid isn't there, that's ok, as it will be
			// automatically added later.
			mGrid = cmd_line_grid;
		}
		
	}
	else
	{
		// if a grid was not passed in via the command line, grab it from the CurrentGrid setting.
		// if there's no current grid, that's ok as it'll be either set by the value passed
		// in via the login uri if that's specified, or will default to maingrid
		mGrid = gSavedSettings.getString("CurrentGrid");
	}
	
	if(mGrid.empty())
	{
		// no grid was specified so default to maingrid
		LL_DEBUGS("GridManager") << "Setting grid to MAINGRID as no grid has been specified " << LL_ENDL;
		mGrid = MAINGRID;
		
	}
	
	// generate a 'grid list' entry for any command line parameter overrides
	// or setting overides that we'll add to the grid list or override
	// any grid list entries with.
	LLSD grid = LLSD::emptyMap();	
	
	if(mGridList.has(mGrid))
	{
		grid = mGridList[mGrid];
	}
	else
	{
		grid[GRID_VALUE] = mGrid;
		// add the grid with the additional values, or update the
		// existing grid if it exists with the given values
		addGrid(grid);		
	}

	LLControlVariablePtr grid_control = gSavedSettings.getControl("CurrentGrid");
	if (grid_control.notNull())
	{
		grid_control->getSignal()->connect(boost::bind(&LLGridManager::updateIsInProductionGrid, this));
	}

	// since above only triggers on changes, trigger the callback manually to initialize state
	updateIsInProductionGrid();
	

	LL_DEBUGS("GridManager") << "Selected grid is " << mGrid << LL_ENDL;		
	setGridChoice(mGrid);
	if(mGridList[mGrid][GRID_LOGIN_URI_VALUE].isArray())
	{
		llinfos << "is array" << llendl;
	}
}
Example #24
0
// <AW opensim>
void LLGridManager::gridInfoResponderCB(GridEntry* grid_entry)
{
	for (LLXMLNode* node = grid_entry->info_root->getFirstChild(); node != NULL; node = node->getNextSibling())
	{
		std::string check;
		check = "login";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
			grid_entry->grid[GRID_LOGIN_URI_VALUE].append(node->getTextContents());
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_LOGIN_URI_VALUE] << LL_ENDL;
			continue;
		}
		check = "gridname";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_LABEL_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_LABEL_VALUE] << LL_ENDL;
			continue;
		}
		check = "gridnick";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_NICK_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_NICK_VALUE] << LL_ENDL;
			continue;
		}
		check = "welcome";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_LOGIN_PAGE_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_LOGIN_PAGE_VALUE] << LL_ENDL;
			continue;
		}
		check = GRID_REGISTER_NEW_ACCOUNT;
		if (node->hasName(check))
		{
			grid_entry->grid[check] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[check] << LL_ENDL;
			continue;
		}
		check = GRID_FORGOT_PASSWORD;
		if (node->hasName(check))
		{
			grid_entry->grid[check] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[check] << LL_ENDL;
			continue;
		}
		check = "help";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_HELP] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_HELP] << LL_ENDL;
			continue;
		}
		check = "about";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_ABOUT] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_ABOUT] << LL_ENDL;
			continue;
		}
		check = "search";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_SEARCH] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_SEARCH] << LL_ENDL;
			continue;
		}
		check = "SendGridInfoToViewerOnLogin";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_SENDGRIDINFO] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_SENDGRIDINFO] << LL_ENDL;
			continue;
		}
		check = "DirectoryFee";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_DIRECTORY_FEE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_DIRECTORY_FEE] << LL_ENDL;
			continue;
		}
		check = "CurrencySymbol";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_CURRENCY_SYMBOL] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_CURRENCY_SYMBOL] << LL_ENDL;
			continue;
		}
		check = "RealCurrencySymbol";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_REAL_CURRENCY_SYMBOL] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_REAL_CURRENCY_SYMBOL] << LL_ENDL;
			continue;
		}
		check = "MaxGroups";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_MAXGROUPS] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_MAXGROUPS] << LL_ENDL;
			continue;
		}
		check = "platform";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_PLATFORM] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_PLATFORM] << LL_ENDL;
			continue;
		}
		check = "message";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_MESSAGE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_MESSAGE] << LL_ENDL;
			continue;
		}
		check = "helperuri";
		if (node->hasName(check))
		{
			grid_entry->grid[GRID_HELPER_URI_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_HELPER_URI_VALUE] << LL_ENDL;
			//don't continue, also check the next
		}
		check = "economy";
		if (node->hasName(check))
		{	//sic! economy and helperuri is 2 names for the same
			grid_entry->grid[GRID_HELPER_URI_VALUE] = node->getTextContents();
			LL_DEBUGS("GridManager") << "[\""<<check<<"\"]: " << grid_entry->grid[GRID_HELPER_URI_VALUE] << LL_ENDL;
		}
	}


	std::string grid = grid_entry->grid[GRID_VALUE].asString();
	std::string slurl_base(llformat(DEFAULT_HOP_BASE, grid.c_str())); // <AW: hop:// protocol>
	grid_entry->grid[GRID_SLURL_BASE]= slurl_base;

	LLDate now = LLDate::now();
	grid_entry->grid["LastModified"] = now;

	addGrid(grid_entry, FINISH);
}
void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer)
{
	if (mergeIfNewer) 
	{
		LLSD::array_const_iterator it, end = gridInfo.endArray();
		for (it = gridInfo.beginArray(); it != end; ++it) 
		{
			LLSD gridMap = *it;
			if (gridMap.has("default_grids_version")) 
			{
				int version = gridMap["default_grids_version"];
				if (version <= mDefaultGridsVersion) return;
				else break;
			}
		}
		if (it == end) 
		{
			llwarns << "Grid data has no version number." << llendl;
			return;
		}
	}

	llinfos << "Loading grid data." << llendl;

	LLSD::array_const_iterator it, end = gridInfo.endArray();
	for (it = gridInfo.beginArray(); it != end; ++it) 
	{
		LLSD gridMap = *it;
		if (gridMap.has("default_grids_version")) 
		{
			mDefaultGridsVersion = gridMap["default_grids_version"];
		} 
		else if ((gridMap.has("gridnick")  || gridMap.has("gridname")) && gridMap.has("loginuri")) 
		{
			std::string gridnick = gridMap["gridnick"];
			std::string gridname = gridMap["gridname"];
			
			HippoGridInfo* grid;
			GridIterator it = mGridInfo.end();
			for (it = mGridInfo.begin(); it != mGridInfo.end(); ++it)
			{
				if(!gridnick.empty() && (it->second->getGridNick() == gridnick))
				{
					break;
				}
				if(gridnick.empty() && !gridname.empty() && (it->first == gridname))
				{
					break;
				}
			}
				
			bool newGrid = (it == mGridInfo.end());
			if (newGrid || !it->second)
			{
				if(gridname.empty())
				{
					gridname = gridnick;
				}				
				// create new grid info
				grid = new HippoGridInfo(gridname);
			} 
			else 
			{
				// update existing grid info
				grid = it->second;
			}
			grid->setLoginUri(gridMap["loginuri"]);
			if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]);
			if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]);
			if (gridMap.has("gridnick")) grid->setGridNick(gridMap["gridnick"]);
			if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]);
			if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]);
			if (gridMap.has("website")) grid->setWebSite(gridMap["website"]);
			if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]);
			if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]);
			if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]);
			if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]);
			if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]);
			if (gridMap.has("inventory_links")) grid->setSupportsInvLinks(gridMap["inventory_links"]);
			if (gridMap.has("auto_update")) grid->mAutoUpdate = gridMap["auto_update"];
			if (gridMap.has("locked")) grid->mLocked = gridMap["locked"];
			if (newGrid) addGrid(grid);
		}
	}
}
Example #26
0
void CStrategyGrid::SetParam(CString paramname,CString value)
{

	//"交易合约;交易总数量A1;初始价格P1;网格宽度J1;每网格数量N1;交易方向;最大成交数量;最大撤单次数;最大风险;账户;";

	m_params[(LPCTSTR)paramname] = value;

	//还需要将对应的值更新
	if(paramname=="交易合约")
	{
		m_strInstrument = value;
	}
	else if(paramname=="合约乘数")
	{
		m_nInstrumentValue =  atoi(value);
	}
	else if(paramname=="交易总数量A1")
	{
		if(m_nCount==0)
		{
			m_nCount = atoi(value);
			return;
		}

		int newCount = atoi(value);

		if(newCount > m_nCount)
		{
			CString s;
			s.Format("交易总数量改为:%d",newCount);

			AddLog(s.GetBuffer(0));

			addGrid(newCount);
		}
		else if(newCount < m_nCount)
		{
			CString s;
			s.Format("交易总数量改为:%d",newCount);

			AddLog(s.GetBuffer(0));

			subGrid(newCount);
		}

		m_nCount = newCount;

	}
	else if(paramname=="初始价格P1")
	{
		m_beginPrice = atof(value);
	}
	else if(paramname=="网格宽度J1")
	{
		m_J1 = atof(value);
	}
	else if(paramname=="每网格数量N1")
	{
		m_N1 = atof(value);
	}
	else if(paramname=="交易方向")
	{
		m_TradeDirection = atoi(value);
	}
	else if(paramname=="开平方向")
	{
		m_kp = atoi(value);
	}
	else if(paramname=="最大成交数量")
	{
		m_nMaxTradeCount = atoi(value);
	}
	else if(paramname=="最大撤单次数")
	{
		m_nMaxChedanCount = atoi(value);
	}
	else if(paramname=="初始风险")
	{
		m_nMaxLost = atoi(value);
	}
	else if(paramname=="资金回撤")
	{
		m_fProfitBackStop = atof(value);
	}
	else if(paramname=="账户")
	{
		m_fundAccount = value;
	}
}
Example #27
0
QWidget* GUIBuilder::buildGUI(model::gui::Element* root, QWidget *parent )
{
    QWidget* widget = NULL;

    if( widget == NULL ) {
        model::gui::TabLayout* tab_layout = dynamic_cast<model::gui::TabLayout*>( root );
        if( tab_layout != NULL ) {
            widget = addTabLayout( tab_layout, parent );
        }
    }
    if( widget == NULL ) {
        model::gui::Grid* grid = dynamic_cast<model::gui::Grid*>( root );
        if( grid != NULL ) {
            widget = addGrid( grid, parent );
        }
    }
    if( widget == NULL ) {
        model::gui::TextInput* text_input = dynamic_cast<model::gui::TextInput*>( root );
        if( text_input != NULL ) {
            widget = new QLineEdit( parent );
            new StringController( widget,
                                  m_model,
                                  text_input->key(),
                                  true );
        }
    }
    if( widget == NULL ) {
        model::gui::Canvas* canvas = dynamic_cast<model::gui::Canvas*>( root );
        if( canvas != NULL ) {
            widget = addCanvas( canvas, parent );
        }
    }
    if( widget == NULL ) {
        model::gui::Label* label = dynamic_cast<model::gui::Label*>( root );
        if( label != NULL ) {
            widget = new QLabel( parent );
            new StringController( widget,
                                  m_model,
                                  label->key(),
                                  label->showValue() );
        }
    }
    if( widget == NULL ) {
        model::gui::ComboBox* combobox = dynamic_cast<model::gui::ComboBox*>( root );
        if( combobox != NULL ) {
            widget = addCombobox( combobox, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::ElementGroup* element_group = dynamic_cast<model::gui::ElementGroup*>( root );
        if( element_group != NULL ) {
            widget = addElementGroup( element_group, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::RadioButtons* radio_buttons = dynamic_cast<model::gui::RadioButtons*>( root );
        if( radio_buttons != NULL ) {
            widget = addRadiobuttons( radio_buttons, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::SpinBox* spin_box = dynamic_cast<model::gui::SpinBox*>( root );
        if( spin_box != NULL ) {
            widget = addSpinBox( spin_box, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::CheckBox* check_box = dynamic_cast<model::gui::CheckBox*>( root );
        if( check_box != NULL ) {
            widget = addCheckBox( check_box, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::Button* button = dynamic_cast<model::gui::Button*>( root );
        if( button != NULL ) {
            widget = addButton( button, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::HorizontalSlider* horizontal_slider = dynamic_cast<model::gui::HorizontalSlider*>( root );
        if( horizontal_slider != NULL ) {
            widget = addHorizontalSlider( horizontal_slider, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::HorizontalLayout* horizontal_layout = dynamic_cast<model::gui::HorizontalLayout*>( root );
        if( horizontal_layout != NULL ) {
            widget = addHorizontalLayout( horizontal_layout, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::VerticalLayout* vertical_layout = dynamic_cast<model::gui::VerticalLayout*>( root );
        if( vertical_layout != NULL ) {
            widget = addVerticalLayout( vertical_layout, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::DoubleSpinBox* double_spinbox = dynamic_cast<model::gui::DoubleSpinBox*>( root );
        if( double_spinbox != NULL ) {
            widget = addDoubleSpinBox( double_spinbox, parent);
        }
    }
    if( widget == NULL ) {
        model::gui::PopupButton* popup_button = dynamic_cast<model::gui::PopupButton*>( root );
        if( popup_button != NULL ) {
            widget = addPopupButton( popup_button, parent );
        }
    }
    if(widget == NULL ) {
       model::gui::FileDialogButton* file_dialog_button = dynamic_cast<model::gui::FileDialogButton*>( root );
       if(file_dialog_button != NULL)
       {
          widget = addFileDialogButton(file_dialog_button, parent);
       }
    }

    if( widget != NULL ) {

        if( !root->visibilityKey().empty() ) {
            new VisibilityController( widget,
                                      m_model,
                                      root->visibilityKey(),
                                      root->visibilityInverted() );
        }
        if( !root->enabledKey().empty() ) {
            new EnabledController( widget,
                                   m_model,
                                   root->enabledKey(),
                                   root->enabledInverted() );
        }
    }

    return widget;
}