Example #1
0
void ColorDialog::indexSelected(QPoint /*p*/)
{
	QPoint hs_pos(m_hsLabel->selectedIndex());
	QPoint v_pos(m_vLabel->selectedIndex());
	int h = qBound(0, hs_pos.x(), 359);
	int s = qBound(0, hs_pos.y(), 255);
	int v = qBound(0, v_pos.y(), 255);
	setSelectedColor(QColor::fromHsv(h, s, v, m_aSpinBox->value()));
	emit colorSelected(selectedColor);
}
Example #2
0
void Illusion_ExcelFile::set_cell_int(long iline, long icolumn, int new_int)
{
    _variant_t new_value((long)new_int);

    _variant_t v_pos("A1");
    CRange start_range = excel_work_sheet_.get_Range(v_pos, CONST_VARIANT_OPTIONAL);

    _variant_t v_row((long)iline - 1);
    _variant_t v_column((long)icolumn - 1);

    CRange write_range = start_range.get_Offset(v_row, v_column);
    write_range.put_Value2(new_value);
    start_range.ReleaseDispatch();
    write_range.ReleaseDispatch();
}
Example #3
0
// NB STILL GETS CAUGHT IN LOCAL MINIMA AND NODES OVERLAP!
void NiceGraph::fruchtermanReingoldLayout(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
{
	float volume = (xmax - xmin) * (ymax - ymin) * (zmax - zmin);
	float k = 1000 * pow( ( volume / getNumVertices()),1.0f/3.0f );
	if ((zmin == 0) && (zmax ==0))
		k = pow (k,3.0f/2.0f); // for a two dimensional constant

	int iterations = 100;	// this value is arbitrary


	// use FR "quadrant variation" on 1/5 largest axes in zone
	// ie only calculate repulsion within the zone
	float zone = max(xmax - xmin, ymax - ymin);
	zone = max(zone, zmax - zmin);
	zone = zone;
	float t = zone;		// arbitrary initial temperature
	
	// do some arbitrary number of iterations
	for (int i = 0; i < iterations; i++)
	{
		map<int,float> dx,dy,dz; // store displacements by vertex ID until the end
		
		//calculate repulsive forces
		for (map<int,Vertex*>::iterator pU = vertexList.begin(); pU != vertexList.end(); pU++)
		{	// initialize values
			int u_id = pU->first;
			vector<float> u_pos(3);
			getXYZPos (u_id, u_pos);
			for (map<int,Vertex*>::iterator pV = vertexList.begin(); pV != vertexList.end(); pV++)
			{
				vector<float> v_pos(3);
				getXYZPos(pV->first, v_pos);
				float diffx =	v_pos[0]-u_pos[0];
				float diffy =   v_pos[1]-u_pos[1];
				float diffz =   v_pos[2]-u_pos[2];
				float dr = sqrt (diffx*diffx+diffy*diffy+diffz*diffz);		
				if (dr < zone)	// only do the calculations if U is within the zone of V
				{
					float force_r = 0;
					float scale = 0;
					if (dr == 0)
					{
						force_r = -100;
						scale = 1;
					}
					else
					{
						force_r = -1.0*(k * k)/dr; 
						scale = dr;
					}
					dx[u_id] += force_r * diffx/scale ;
					dy[u_id] += force_r * diffy/scale ;
					dz[u_id] += force_r * diffz/scale ;
				}
			}
		}
		
		// calculate attractive forces
		for (map<int,Edge*>::iterator pE = edgeList.begin(); pE != edgeList.end(); pE++)
		{
			vector<float> u_pos(3), v_pos(3);
			getEndpoints(pE->first, u_pos, v_pos);
			float diffx =	v_pos[0]-u_pos[0];
			float diffy =   v_pos[1]-u_pos[1];
			float diffz =   v_pos[2]-u_pos[2];
			float dr = sqrt (diffx*diffx + diffy*diffy + diffz*diffz);	

			float force_a = (dr*dr)/k;
			float scale = dr;
			if (dr ==0) scale = -1.0;
			dx[pE->second->from->vID] += force_a * diffx/scale ;
			dy[pE->second->from->vID] += force_a * diffy/scale ;
			dz[pE->second->from->vID] += force_a * diffz/scale ;
			dx[pE->second->to->vID] += -1.0 * force_a * diffx/scale ;
			dy[pE->second->to->vID] += -1.0 * force_a * diffy/scale ;
			dz[pE->second->to->vID] += -1.0 * force_a * diffz/scale ;
		}
	
		// now do bounds checking and update all the positions
		for (map<int,Vertex*>::iterator V = vertexList.begin(); V != vertexList.end(); V++)
		{
			int id = V->first;
			vector<float> p(3);
			getXYZPos(id,p);
			p[0] += min (dx[id],t);
			p[1] += min (dy[id],t);			
			p[2] += min (dz[id],t);			
			// also do bounds checking on frame??
			p[0] = min(xmax,max(xmin,p[0]));
			p[1] = min(ymax,max(ymin,p[1]));
			p[2] = min(zmax,max(zmin,p[2]));
			
			setXYZPos(id, p[0], p[1], p[2]);
		}
		// now cool the temperature a bit
		t*=.98;
	}
}