Beispiel #1
0
// -----------------------------------------------
// ProgressBar
// -----------------------------------------------
void * ehzProgressBar(struct OBJ *objCalled,EN_MESSAGE cmd,LONG info,void *ptr)
{
	 EH_DISPEXT *DExt=ptr;
//	 SINT *lpi;
	 SINT iLx,iLy;
	 SINT iRiemp;
	 SINT iPos;
	 SINT iBar;
	 SINT iDiv;
	 SINT a;
	 SINT ThePoint;
	 SINT iMyShadow;
	 SINT iEnd;
	 EH_PROGRESS_BAR * psBar;

	 //lpi=(SINT *) objCalled->text;
	 psBar=(EH_PROGRESS_BAR *) objCalled->pOther;

	 switch(cmd) {
		case WS_INF: return NULL;

		case WS_CREATE:
			psBar=objCalled->pOther=ehAllocZero(sizeof(EH_PROGRESS_BAR));
			psBar->iMax=100;
			psBar->cBar=sys.Color3DHighLight;
			if (!strcmp(objCalled->text,"WIN")) {
				objCalled->hWnd=CreateWindowEx(0,
								   PROGRESS_CLASS, 
								   NULL,
								   WS_CHILD|WS_VISIBLE,
								   0,0,
								   10,10,//-(MENU_HEIGHT),
								   WindowNow(),//sGMSetup.hwAnagTB,//sGMSetup.hwAnag,
								   (HMENU) NULL,
								   sys.EhWinInstance,
								   NULL);
				SendMessage(objCalled->hWnd, PBM_SETRANGE,0,MAKELPARAM(0,100));
				SendMessage(objCalled->hWnd, PBM_SETSTEP, MAKEWPARAM(1, 0), 0);
			} else objCalled->hWnd=NULL;

			break;

		case WS_DESTROY:
			ehFreePtr(&objCalled->pOther);
			if (objCalled->hWnd) DestroyWindow(objCalled->hWnd);
			break;

		case WS_DO: // Spostamento / Ridimensionamento
			MoveWindow(objCalled->hWnd,DExt->px,DExt->py,DExt->lx,DExt->ly,TRUE);
			break;

		case WS_SETFLAG:

			if (!strcmp(ptr,"MAX")) // Setta lo stile della finestra
			{
				if (info<1) info=1;
				//*psBar->iMax=info;
				psBar->iMax=info;
			}
			
			if (!strcmp(ptr,"COL")) // Setta lo stile della finestra
			{
//				*(lpi+3)=info;
				psBar->cBar=info;
				obj_vedisolo(objCalled->nome);
			}
			
			if (!strcmp(ptr,"CNT")) // Setta lo stile della finestra
			{
				//*lpi=info;
				psBar->iCount=info;

				// Calcolo percentuale
				iRiemp=psBar->iCount; if (iRiemp>(psBar->iMax)) iRiemp=psBar->iMax; 
				iPos=0;
				if (psBar->iMax) iPos=100*iRiemp/psBar->iMax;// calcolo percntuale di riempimento
			
				// Se la percentuale è cambiata ristampo il tutto
				if (psBar->iPerc!=iPos) {
					psBar->iPerc=iPos; 
					if (objCalled->hWnd)
						SendMessage(objCalled->hWnd, PBM_SETPOS, psBar->iPerc, 0); 
						else
						obj_vedisolo(objCalled->nome);
				}

				//if (*lpi!=info) {*lpi=info; obj_vedisolo(objCalled->nome);}
			}

			break;


		case WS_DISPLAY: 
			if (objCalled->hWnd) {InvalidateRect(objCalled->hWnd,NULL,TRUE); break;}

			iLx=DExt->px+DExt->lx-1; iLy=DExt->py+DExt->ly-1;
			iRiemp=psBar->iCount;  if (iRiemp>(psBar->iMax)) iRiemp=psBar->iMax;
			iPos=100*iRiemp/psBar->iMax;// calcolo percentuale di riempimento
			iBar=(DExt->lx-3)*iRiemp/psBar->iMax;// Calcolo dimensione barra pieno
			iDiv=(DExt->px+iBar);

 			//Tbox(DExt->px,DExt->py,iLx,iLy,0,SET);
			box3d(DExt->px,DExt->py,iLx,iLy,1);
//			dispf(iText,DExt->py,15,-1,ON,"SMALL F",3,szServ);
			ThePoint=(DExt->ly/3);
			iMyShadow=ColorLum(sys.Color3DShadow,-30);
			if (iBar>0) 
			{
				 Tline(DExt->px+1,DExt->py+1,iDiv,DExt->py+1,iMyShadow,SET);
				 for (a=2;a<DExt->ly-2;a++) {

					 LONG Col;
					 if (a<ThePoint) 
						Col=ColorFusion(sys.Color3DShadow,psBar->cBar,(100/ThePoint*a));
						else
						Col=ColorFusion(sys.Color3DShadow,psBar->cBar,(100/(DExt->ly-ThePoint)*(DExt->ly-a)));
//					 iEnd=iDiv+a-2; if (iEnd>iLx-1) iEnd=iLx-1;
					 iEnd=iDiv-2; if (iEnd>iLx-1) iEnd=iLx-1;
					 Tline(DExt->px+2,DExt->py+a,iEnd,DExt->py+a,Col,SET);
				 }
				 Tline(DExt->px+1,iLy-1,iEnd,iLy-1,ColorLum(sys.Color3DShadow,-40),SET);
			}

			ThePoint=DExt->ly-ThePoint;
			if (iBar<(DExt->lx-2)) 
			{//Tboxp(iDiv+1,DExt->py+2,iDiv+1,iLy-2,0,SET);
			 //Tboxp(iDiv+2,DExt->py+1,iLx-1,iLy-1,ColorLum(sys.Color3DShadow,-10),SET);
			 for (a=1;a<DExt->ly-1;a++)
			 {
			  LONG Col;
			  if (a<ThePoint) Col=ColorFusion(iMyShadow,sys.Color3DLight,(100/ThePoint*a));
							  else
							  Col=ColorFusion(iMyShadow,sys.Color3DLight,(100/(DExt->ly-ThePoint)*(DExt->ly-a)));
//				if (iBar>0) {iEnd=iDiv+a; if (iEnd>iLx-1) iEnd=iLx-1;} else iEnd=iDiv+1;
				if (iBar>0) {iEnd=iDiv-1; if (iEnd>iLx-1) iEnd=iLx-1;} else iEnd=iDiv+1;
				Tline(iEnd,DExt->py+a,iLx-1,DExt->py+a,Col,SET);
			 }
			}

			//sys.fFontBold=FALSE;
			break;
	}
	return NULL;
}
Beispiel #2
0
/*
 * This method is the implementation of the HyCon3D algorithm.
 * This algorithm computes the exclusive contribution to the hypervolume by every point, using an efficient HyCon3D algorithm by Emmerich and Fonseca.
 *
 * @see "Computing hypervolume contribution in low dimensions: asymptotically optimal algorithm and complexity results", Michael T. M. Emmerich, Carlos M. Fonseca
 *
 * @param[in] points vector of points containing the 3-dimensional points for which we compute the hypervolume
 * @param[in] r_point reference point for the points
 * @return vector of exclusive contributions by every point
 */
std::vector<double> hv3d::contributions(std::vector<fitness_vector> &points, const fitness_vector &r_point) const
{
	// Make a copy of the original set of points
	std::vector<fitness_vector> p(points.begin(), points.end());

	std::vector<std::pair<fitness_vector, unsigned int> > point_pairs;
	point_pairs.reserve(p.size());
	for(unsigned int i = 0 ; i < p.size() ; ++i) {
		point_pairs.push_back(std::make_pair(p[i], i));
	}
	if (m_initial_sorting) {
		sort(point_pairs.begin(), point_pairs.end(), hycon3d_sort_cmp);
	}
	for(unsigned int i = 0 ; i < p.size() ; ++i) {
		p[i] = point_pairs[i].first;
	}


	typedef std::multiset<std::pair<fitness_vector, int>, hycon3d_tree_cmp > tree_t;

	unsigned int n = p.size();
	const double INF = std::numeric_limits<double>::max();

	// Placeholder value for undefined lower z value.
	const double NaN = INF;

	// Contributions
	std::vector<double> c(n, 0.0);

	// Sentinel points
	fitness_vector s_x(3, -INF); s_x[0] = r_point[0]; // (r,oo,oo)
	fitness_vector s_y(3, -INF); s_y[1] = r_point[1]; // (oo,r,oo)
	fitness_vector s_z(3, -INF); s_z[2] = r_point[2]; // (oo,oo,r)

	p.push_back(s_z); // p[n]
	p.push_back(s_x); // p[n + 1]
	p.push_back(s_y); // p[n + 2]

	tree_t T;
	T.insert(std::make_pair(p[0], 0));
	T.insert(std::make_pair(s_x, n + 1));
	T.insert(std::make_pair(s_y, n + 2));

	// Boxes
	std::vector<std::deque<box3d> > L(n + 3);

	box3d b(r_point[0], r_point[1], NaN, p[0][0], p[0][1], p[0][2]);
	L[0].push_front(b);

	for (unsigned int i = 1 ; i < n + 1 ; ++i) {
		std::pair<fitness_vector, int> pi(p[i], i);

		tree_t::iterator it = T.lower_bound(pi);

		// Point is dominated
		if (p[i][1] >= (*it).first[1]) {
			return wfg(2).contributions(points, r_point);
		}

		tree_t::reverse_iterator r_it(it);

		std::vector<int> d;

		while((*r_it).first[1] > p[i][1]) {
			d.push_back((*r_it).second);
			++r_it;
		}

		int r = (*it).second;
		int t = (*r_it).second;

		T.erase(r_it.base(), it);

		// Process right neighbor region, region R
		while(!L[r].empty()) {
			box3d& b = L[r].front();
			if(b.ux >= p[i][0]) {
				b.lz = p[i][2];
				c[r] += box_volume(b);
				L[r].pop_front();
			} else if(b.lx > p[i][0]) {
				b.lz = p[i][2];
				c[r] += box_volume(b);
				b.lx = p[i][0];
				b.uz = p[i][2];
				b.lz = NaN;
				break;
			} else {
				break;
			}
		}

		// Process dominated points, region M
		double xleft = p[t][0];
		std::vector<int>::reverse_iterator r_it_idx = d.rbegin();
		std::vector<int>::reverse_iterator r_it_idx_e = d.rend();
		for(;r_it_idx != r_it_idx_e ; ++r_it_idx) {
			int jdom = *r_it_idx;
			while(!L[jdom].empty()) {
				box3d& b = L[jdom].front();
				b.lz = p[i][2];
				c[jdom] += box_volume(b);
				L[jdom].pop_front();
			}
			L[i].push_back(box3d(xleft, p[jdom][1], NaN, p[jdom][0], p[i][1], p[i][2]));
			xleft = p[jdom][0];
		}
		L[i].push_back(box3d(xleft, p[r][1], NaN, p[i][0], p[i][1], p[i][2]));
		xleft = p[t][0];

		// Process left neighbor region, region L
		while(!L[t].empty()) {
			box3d &b = L[t].back();
			if(b.ly > p[i][1]) {
				b.lz = p[i][2];
				c[t] += box_volume(b);
				xleft = b.lx;
				L[t].pop_back();
			} else {
				break;
			}
		}
		if (xleft > p[t][0]) {
			L[t].push_back(box3d(xleft, p[i][1], NaN, p[t][0], p[t][1], p[i][2]));
		}
		T.insert(std::make_pair(p[i], i));
	}

	// Fix the indices
	std::vector<double> contribs(n, 0.0);
	for(unsigned int i=0;i < c.size();++i) {
		contribs[point_pairs[i].second] = c[i];
	}
	return contribs;
}