Пример #1
0
void Item :: createFile()
{
	ofstream outFile;
	char ch;
	outFile.open("ITEM.DAT",ios::binary);
	do
	{
	  clrBox(34,8,70,23);
	  whiteColor();
	  drawBoxTwo(34,11,70,23);
	  gotoxy(46,9);
	  headingColor();
	  cprintf("STOCK CREATION");
	  lightcyanColor();
	  a.getRecord();
	  outFile.write( (char*)&a,sizeof(a) );
	  whiteColor();
	  drawBox(35,20,69,22);
	  gotoxy(37,21);
	  textcolor(YELLOW+BLINK);
	  cprintf("Record is successfully inserted");
	  gotoxy(37,24);
	  yellowColor();
	  cprintf("Do you want to continue (Y/N) ? ");
	  cin >>ch;
	  ch=toupper(ch);
	  gotoxy(37,24);
	  clreol();
	} while ( ch=='Y');
	outFile.close();
}
void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) {
    if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
        Q_ASSERT(args->_batch);
        gpu::Batch& batch = *args->_batch;

        batch.setModelTransform(entity->getTransformToCenter()); // we want to include the scale as well
        
        auto nodeList = DependencyManager::get<NodeList>();
        const QUuid& myNodeID = nodeList->getSessionUUID();
        bool highlightSimulationOwnership = (entity->getSimulatorID() == myNodeID);
        if (highlightSimulationOwnership) {
            glm::vec4 greenColor(0.0f, 1.0f, 0.2f, 1.0f);
            renderBoundingBox(entity, args, 0.08f, greenColor);
        }

        quint64 now = usecTimestampNow();
        if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
            glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f);
            renderBoundingBox(entity, args, 0.16f, redColor);
        }

        if (now - entity->getLastBroadcast() < 0.2f * USECS_PER_SECOND) {
            glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f);
            renderBoundingBox(entity, args, 0.24f, yellowColor);
        }

        ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
        if (motionState && motionState->isActive()) {
            glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
            renderBoundingBox(entity, args, 0.32f, blueColor);
        }
    }
}
Пример #3
0
void Widget::drawWidget(QPainter &qp) {

    QString num[] = { "75", "150", "225", "300", "375", "450",
                      "525", "600", "675" };

    int asize = sizeof(num)/sizeof(num[1]);

    QColor redColor(255, 175, 175);
    QColor yellowColor(255, 255, 184);

    int width = size().width();

    Burning *burn = (Burning *) m_parent;
    int cur_width = burn->getCurrentWidth();

    int step = (int) qRound((double)width / DIVISIONS);
    int till = (int) ((width / MAX_CAPACITY) * cur_width);
    int full = (int) ((width / MAX_CAPACITY) * FULL_CAPACITY);

    if (cur_width >= FULL_CAPACITY) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, full, 30);
        qp.setPen(redColor);
        qp.setBrush(redColor);
        qp.drawRect(full, 0, till-full, PANEL_HEIGHT);

    } else if (till > 0) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, till, PANEL_HEIGHT);
    }

    QColor grayColor(90, 80, 60);
    qp.setPen(grayColor);

    for (int i=1; i <=asize; i++) {

        qp.drawLine(i*step, 0, i*step, LINE_WIDTH);
        QFont newFont = font();
        newFont.setPointSize(7);
        setFont(newFont);

        QFontMetrics metrics(font());

        int w = metrics.width(num[i-1]);
        qp.drawText(i*step-w/2, DISTANCE, num[i-1]);
    }
}
Пример #4
0
bool LineDetector::GetLines(Mat &rawHSV, Mat & fieldMask,
		Mat &guiImg, bool SHOWGUI, const Mat &lineBinary,
		vector<LineSegment> &resLines)
{
	int MIN_LINE_DOUBLE_VOTE = params.line.lineVoteDouble->get();
	int MIN_LINE_VOTE = params.line.lineVote->get();
	int MIN_LINE_COLOR_VOTE = params.line.lineVoteColor->get();
	vector<Vec4i> linesP;
	HoughLinesP(lineBinary, linesP, 1, M_PI / 45, 20,
			params.line.MinLineLength->get(), 20);

	for (size_t i = 0; i < linesP.size(); i++)
	{
		Vec4i lP = linesP[i];
		LineSegment tmpLine(Point2d(lP[0], lP[1]), Point2d(lP[2], lP[3]));

		vector<cv::Point2d> midds = tmpLine.GetMidPoints(3); //2^3+1 = 16
		int lineVoter = 0;
		int vote_for_double = 0;
		int vote_for_color = 0;
		uchar *dataImg = fieldMask.data;
		//	printf("size= %d\n", midds.size());
		for (size_t j = 0; j < midds.size(); j++)
		{

			int jumpMin = params.line.jumpMin->get();
			int jumpMax = params.line.jumpMin->get();
			double distanceToZero = GetDistance(
					cv::Point2d((params.camera.width->get() / 2),
							(params.camera.height->get())), midds[j]);
			LineInterpolation interP(
					LineSegment(cv::Point2d(0, jumpMax),
							cv::Point2d(params.camera.height->get(), jumpMin)));
			double jump;
			if (!interP.GetValue(distanceToZero, jump))
			{
				//printh(CRed, "Error In Programming!");
				continue;
			}
			LineSegment tocheck = tmpLine.PerpendicularLineSegment(jump,
					midds[j]);
			cv::LineIterator it(lineBinary, tocheck.P1, tocheck.P2, 8);

			vector<uchar> buf(it.count);

			int currentCounter = 0;
			for (int k = 0; k < it.count; k++, ++it)
			{
				uchar val=*(*it);
				if ( val > 10)
				{
					vote_for_double++;
					currentCounter++;
				}
				if (currentCounter >= 2)
					break;
			}

			cv::LineIterator itHSV(rawHSV, tocheck.P1, tocheck.P2, 8);

			vector<uchar> bufHSV(itHSV.count);

			for (int k = 0; k < itHSV.count; k++, ++itHSV)
			{
				cv::Vec3b hsvC = (cv::Vec3b) *itHSV;
				if (hsvC[0] >= params.line.h0->get()
						&& hsvC[0] <= params.line.h1->get()
						&& hsvC[1] >= params.line.s0->get()
						&& hsvC[1] <= params.line.s1->get()
						&& hsvC[2] >= params.line.v0->get()
						&& hsvC[2] <= params.line.v1->get())
				{
					vote_for_color++;
					break;
				}
			}

			int safeToShow = 0;
			if (tocheck.P1.x >= 0 && tocheck.P1.y >= 0
					&& tocheck.P1.x < params.camera.width->get()
					&& tocheck.P1.y < params.camera.height->get())
			{
				safeToShow++;
				uchar* pixelP = dataImg
						+ ((((int) tocheck.P1.y * params.camera.width->get())
								+ (int) tocheck.P1.x) * 1);
				if (*pixelP > 50)
					lineVoter++;
			}
			if (tocheck.P2.x >= 0 && tocheck.P2.y >= 0
					&& tocheck.P2.x < params.camera.width->get()
					&& tocheck.P2.y < params.camera.height->get())
			{
				safeToShow++;
				uchar* pixelP = dataImg
						+ ((((int) tocheck.P2.y * params.camera.width->get())
								+ (int) tocheck.P2.x) * 1);
				if (*pixelP > 50)
					lineVoter++;
			}

			if (safeToShow >= 2)
			{
				if (SHOWGUI && params.debug.showLineD->get())
				{
					cv::line(guiImg, tocheck.P1, tocheck.P2, yellowColor(), 1);
				}
			}
		}
		if (lineVoter > MIN_LINE_VOTE && vote_for_double > MIN_LINE_DOUBLE_VOTE
				&& vote_for_color > MIN_LINE_COLOR_VOTE)
			resLines.push_back(tmpLine);

	}
	return resLines.size() > 0;

}
Пример #5
0
void Item::Billing()
{
	normalColor();
	clrscr();
	ifstream inFile;
	inFile.open("ITEM.DAT",ios::in | ios::binary);
	if(!inFile)
	{
		gotoxy(30,12);
		warningColor();
		cprintf("File does not exist!!");
		cout<<'\a';
		delay(500);
		normalColor();
		return;
	}
	fstream recordBill("BILLS.TXT",ios::app);
	inFile.close();
	char* time;
	int billNo;
	int sNo=0;
	int sQty;
	int iNo;
	int itemK=0;
	int lcount;
	float price;
	float amount=0;
	billNo=nextBillNo();
	time=getTime();
	clrscr();
	gotoxy(30,1);
	headingColor();
	cprintf("ABC STORES MANAGEMENT");
	gotoxy(30,2);
	cprintf("---------------------");
	gotoxy(37,3);
	cprintf("BILLING");
	gotoxy(37,4);
	cprintf("-------");
	gotoxy(4,4);
	yellowColor();
	time=getTime();
	cprintf("%s",time);
	lcount=8;
	do
	{
		sNo++;
		whiteColor();
		drawBox(3,5,55,23);
		gotoxy(3,25);
		yellowColor();
		cprintf("Type '0' to item# to end input");
		gotoxy(4,7);
		whiteColor();
		horLine(4,54);
		lightgreenColor();
		gotoxy(5,6);
		cprintf("Item#  Name           Qty       Rate   Price");
		clrBox(57,5,80,23);
		whiteColor();
		drawBox(57,5,80,23);
		gotoxy(58,7);
		whiteColor();
		horLine(58,79);
		lightgreenColor();
		gotoxy(59,6);
		cprintf("Item#  Name");
		normalColor();
		inFile.open("ITEM.DAT",ios::binary);
		int line=8;
		inFile.read((char*)&a,sizeof(a));
		while(inFile)
		{
			gotoxy(59,line); cprintf("%d",itemNo);
			gotoxy(66,line); cprintf("%s",name);
			line++;
			inFile.read((char*)&a,sizeof(a));
		}
		inFile.close();
		gotoxy(5,lcount);
		cin>>iNo;
		if(iNo==0)
		{
			gotoxy(3,25);
			clreol();
			gotoxy(5,lcount);
			clrBox(5,lcount,10,lcount);
			clrBox(57,5,80,23);
			gotoxy(39,lcount+1);
			cprintf("------------");
			gotoxy(30,lcount+2);
			cprintf("Amount = Rs. ");
			gotoxy(43,lcount+2);
			cout<<setw(6)<<amount;
			gotoxy(39,lcount+3);
			cprintf("------------");
			gotoxy(4,lcount+4);
			whiteColor();
			drawBox(4,lcount+4,54,lcount+6);
			gotoxy(20,lcount+5);
			normalColor();
			cprintf("PLEASE PAY Rs. %.2f",amount);
			getch();
			if(itemK)
			{
				recordBill<<"Bill No. "<<billNo<<'\t'<<time;
				recordBill<<"Amount = Rs. "<<amount<<'\n'<<'\n'<<'\n'<<'\n';
			}
			 else
			 {
				ofstream outFile;
				outFile.open("BILL_NO.TXT");
				outFile<<billNo;
			 }
			return;
		}
		inFile.open("ITEM.DAT",ios::binary);
		inFile.read((char*)&a,sizeof(a));
		boolean found=FALSE;
		while(!inFile.eof() && (!found))
		{
			if(iNo==a.itemNo)
				found=TRUE;
			else
				inFile.read((char*)&a, sizeof(a));
		}
		if(found)
		{
			itemK++;
			gotoxy(12,lcount);
			cprintf("%s",a.name);
			clrBox(57,5,80,23);
			whiteColor();
			drawBox(57,5,80,23);
			gotoxy(58,7);
			whiteColor();
			horLine(58,79);
			gotoxy(59,6);
			line=8;
			yellowColor();
			cprintf("Item#    Qty");
			normalColor();
			gotoxy(60,line); cprintf("%d",itemNo);
			gotoxy(68,line); cprintf("%d",qty);
			do
			{
				gotoxy(27,lcount);
				cin>>sQty;
				if(sQty>qty)
				{
					clrBox(27,lcount,35,lcount);
					cout<<'\a';
				}
			}while(sQty>qty);
			fstream modifyFile;
			modifyFile.open("ITEM.DAT",ios::in | ios::out | ios::binary);
			modifyFile.read( (char*)&a,sizeof(a) );
			found = FALSE;
			int rec = 0;
			while( (!modifyFile.eof()) && (!found) )
			{
				rec++;
				if(iNo == a.itemNo)
				{
					a.qty-=sQty;
					modifyFile.seekg( (rec-1)*sizeof(a),ios::beg);
					modifyFile.write( (char*)&a, sizeof(a) );
					found = TRUE;
				}
				else
					modifyFile.read( (char*)&a, sizeof(a) );
			}
			modifyFile.close();
			gotoxy(35,lcount);
			cout<<setw(6)<<rate;
			price=sQty*rate;
			gotoxy(43,lcount);
			cout<<setw(6)<<price;
			amount+=price;
			recordBill<<setw(7)<<setiosflags(ios::left)
				 <<setiosflags(ios::fixed)<<sNo;
			recordBill<<setw(18)<<setiosflags(ios::left)
				 <<setiosflags(ios::fixed)<<a.name;
			recordBill<<setw(10)<<setiosflags(ios::left)
				 <<setiosflags(ios::fixed)<<sQty;
			recordBill<<setw(10)<<setiosflags(ios::left)
				 <<setiosflags(ios::fixed)<<a.rate;
			recordBill<<setw(10)<<setiosflags(ios::left)
				 <<setiosflags(ios::fixed)<<price;
			recordBill.put('\n');
			lcount++;
		}
		else
		{
			gotoxy(5,lcount);
			clrBox(5,lcount,10,lcount);
			cout<<'\a';
		}
		inFile.close();
		if(lcount+5==22)
		{
			clrBox(3,5,55,23);
			lcount=8;
		}
	}while(iNo!=0);