Exemple #1
0
	MAExtent Font::getStringDimensions(const char *strS, int length) const {
		if(length == 0) return EXTENT(0, 0);
		MAPoint2d cursor = {0, 0};
		int width = 0, height = mCharset->lineHeight;
		if(!mFontImage) return EXTENT(0, 0);
		CharDescriptor *chars = mCharset->chars;
		int i = 0;
		const unsigned char* str = (const unsigned char*)strS;
		while(*str && (i!=length)) {
			if((*str)=='\n')
			{
				cursor.x = 0;//chars[*str].xAdvance;
				cursor.y += mCharset->lineHeight + mLineSpacing;
				height += mCharset->lineHeight + mLineSpacing;
				str++;
				i++;
				continue;
			}

			cursor.x += chars[*str].xAdvance;

			if(cursor.x
				//mCharset.chars[*str].xOffset + mCharset.chars[*str].width
		> width) {
			//width = (cursor.x + mCharset.chars[*str].xOffset + mCharset.chars[*str].width);
				width = cursor.x;
			}

			str++;
			i++;
		}	

		return EXTENT(width, height);
	}
Exemple #2
0
	MAExtent Font::getBoundedStringDimensions(
		const char *strS,
		const Rect &bound,
		int length) const
	{
		if(length == 0) {
			return EXTENT(0, 0);
		}
		if(!mFontImage) {
			return EXTENT(0, 0);
		}

		calcLineBreaks(strS, bound.x, bound.y, bound);

		int i = 0;
		int j = 0;
		//MARect srcRect = {0, 0, 0, 0};
		MAPoint2d cursor = {0, 0};
		int height = 0;
		int width = 0;
		CharDescriptor *chars = mCharset->chars;
		const unsigned char* str = (const unsigned char*)strS;

		while(*str && (i!=length)) {
			if((lineBreaks[j] == i) || ((*str) == '\n')) {
				j++;
				cursor.x = 0;
				cursor.y += mCharset->lineHeight + mLineSpacing;
				str++;
				i++;
				continue;
			}
			else {
				cursor.x += chars[*str].xAdvance;
			}

			// TODO: Clean up formatting, remove commented out code.
			if(cursor.y + mCharset->lineHeight//mCharset.chars[*str].yOffset + mCharset.chars[*str].height
			> height) {
				//height = (cursor.y + mCharset.chars[*str].yOffset + mCharset.chars[*str].height);
				height = cursor.y + mCharset->lineHeight;
			}

			// TODO: Clean up formatting, remove commented out code.
			if(cursor.x//mCharset.chars[*str].xOffset + mCharset.chars[*str].width
			> width) {
				//width = (cursor.x + mCharset.chars[*str].xOffset + mCharset.chars[*str].width);
				width = cursor.x; //cursor.x + mCharset.chars[*str].xAdvance;
			}


			str++;
			i++;
		}
		return EXTENT(width, height);
	}
Exemple #3
0
/**
 * Creates an image with a gray gradient.
 */
Image* ScreenImageSwiper::createBackgroundGradient()
{
	// Create gradient bitmap.
	int *gradientBitmap = new int[16 * 16];
	for (int i = 0; i < 16; ++i)
	{
		for (int j = 0; j<16; ++j)
		{
			int color = 0xFF - (i * 0xFF / 16);
			gradientBitmap[i*16 + j] = color | (color << 8) | (color << 16);
		}
	}

	// Create image with gradient.
	MAHandle imageHandle = maCreatePlaceholder();
	maCreateImageRaw(imageHandle, gradientBitmap, EXTENT(16, 16), 0);
	delete gradientBitmap;

	// Create image widget.
	Image* imageWidget = new Image();
	imageWidget->setImage(imageHandle);
	imageWidget->setPosition(0, 0);
	imageWidget->setSize(
		MAW_CONSTANT_FILL_AVAILABLE_SPACE,
		MAW_CONSTANT_FILL_AVAILABLE_SPACE);

	// Tell image to stretch.
	imageWidget->setProperty("scaleMode", "scaleXY");

	return imageWidget;
}
Exemple #4
0
	void testImageRawData() {
		const unsigned int NUMCOLORS = sizeof(sColors)/sizeof(int);

		unsigned int colors2[NUMCOLORS];

		MAHandle testImg = maCreatePlaceholder();

		printf("imageRawData\n");

		int res = maCreateImageRaw(testImg, sColors, EXTENT(NUMCOLORS,1), 1);
		assert("maCreateImageRaw", res == RES_OK);

		MAExtent e1 = maGetImageSize(testImg);

		assert("maGetImageSize", e1 == EXTENT(NUMCOLORS,1));

		MARect rect = {0, 0, NUMCOLORS, 1};

		maGetImageData(testImg, colors2, &rect, NUMCOLORS);

		assert("image: createRaw then getData",
			(memcmp(sColors, colors2, sizeof(sColors)) == 0)
		);
	}
Exemple #5
0
int MAMain() {
	double SDA = sin(0.0981746875);	//(0x3fb921f9f01b866e) sin error, returning 1
	//) returned 0x000000003ff00000(5.29980882362664E-315)

	InitConsole();
	printf("Floating test");

	DUMPDH(179.288537549407);
	DUMPDH(SDA);

	//return 0;

	Extent scrSize = maGetScrSize();
	scrSize = EXTENT(176, 208);
	double d;

	d = __adddf3(__floatsidf(EXTENT_X(scrSize)), __muldf3(__floatsidf(EXTENT_Y(scrSize)), 63.25));


	d /= 0.0;	//division by zero.

	DUMPD(__floatsidf(EXTENT_X(scrSize)));
	DUMPD(__floatsidf(EXTENT_Y(scrSize)));
	DUMPD(63.25);
	DUMPD(__muldf3(__floatsidf(EXTENT_Y(scrSize)), 63.25));
	d = __adddf3(__floatsidf(EXTENT_X(scrSize)), __divdf3(__floatsidf(EXTENT_Y(scrSize)), 63.25));
	printf("%f %i", d, __fixdfsi(d));
	printf("%f %i", __floatsidf(42), __fixdfsi(__floatsidf(42)));
	printf("%f %i", 63.25, __fixdfsi(63.25));

	printf("%i", dcmp(63.25, 42.0));
	printf("%i", dcmp(42.0, 63.25));
	printf("%i", dcmp(42.0, 42.0));

	DUMPDH(63.25);
	DUMPDH(42.0);
	DUMPDH(__negdf2(63.25));
	DUMPDH(__negdf2(42.0));
	DUMPDH(-63.25);
	DUMPDH(-42.0);
	DUMPDH(2.1470*1000000000.0);
	DUMPDH(2.1475*1000000000.0);	//vsprintf has a bug

	//wait for keypress, then exit
	printf("Press 0 to exit\n");
	FREEZE;
	return 0;
}
Exemple #6
0
	void WidgetSkin::draw(int x, int y, int width, int height, eType type) {
		MAHandle cached = 0;

		// Calculate numTiles needed to be drawn, if they are many, we need to cache, otherwise draw directly...
		int numTiles = calculateNumTiles(width, height);
		if(!useCache || numTiles<100) {
			drawDirect(x, y, width, height, type);
			return;
		}

		CacheKey newKey = CacheKey(this, width, height, type);
		cached =  getFromCache(newKey);

		// If we didn't find a cached widgetskin, let's generate one and save it in the cache.
		if(!cached) {
			// set malloc handler to null so that we can catch if we're out of heap and write directly to the screen then.
			#ifndef MOSYNC_NATIVE
			malloc_handler mh = set_malloc_handler(NULL);
			#endif
			int *data = new int[width*height];
			if(!data) {
				drawDirect(x, y, width, height, type);
				return;
			}
			#ifndef MOSYNC_NATIVE
			set_malloc_handler(mh);
			#endif
			drawToData(data, 0, 0, width, height, type);
			CacheElement cacheElem;

			flushCacheUntilNewImageFits(width*height);

			cacheElem.image = maCreatePlaceholder();
			if(maCreateImageRaw(cacheElem.image,data,EXTENT(width,height),1)!=RES_OK) {
				maPanic(1, "Could not create raw image");
			}

			delete data;
			cacheElem.lastUsed = maGetMilliSecondCount();
			cached = cacheElem.image;
			addToCache(newKey, cacheElem);
		}

		// Draw the cached widgetskin.
		Gfx_drawImage(cached, x, y);
	}
Exemple #7
0
	void testDrawableImages() {
		const unsigned int colors[] = {
			0xff000000,
			0xff0000ff,
			0xff00ff00,
			0xff00ffff,
			0xffff0000,
			0xffff00ff,
			0xffffff00,
			0xffffffff,
		};

		const unsigned int NUMCOLORS = sizeof(colors)/sizeof(int);

		unsigned int colors2[NUMCOLORS];

		MAHandle testImg = maCreatePlaceholder();

		printf("testing resources\n");

		int res = maCreateDrawableImage(testImg, NUMCOLORS, 1);
		assert("maCreateImageRaw", res == RES_OK);

		MAExtent e1 = maGetImageSize(testImg);

		assert("maGetImageSize", e1 == EXTENT(NUMCOLORS,1));

		maSetDrawTarget(testImg);

		for(unsigned int i = 0; i < NUMCOLORS; i++) {
			maSetColor(colors[i]);
			maPlot(i, 0);
		}

		MARect rect = {0, 0, NUMCOLORS, 1};

		maSetDrawTarget(0);

		maGetImageData(testImg, colors2, &rect, NUMCOLORS);

		assert(
				"testing drawable image res",
				(memcmp(colors, colors2, sizeof(colors)) == 0)
		);
	}
Exemple #8
0
	void testGetImageData() {
		printf("testing maGetImageData\n");

		const unsigned int NUMCOLORS = sizeof(sColors)/sizeof(int);
		unsigned int colors2[NUMCOLORS];
		MAExtent e1 = maGetImageSize(ARGB_PNG);

		assert("maGetImageSize", e1 == EXTENT(NUMCOLORS,1));

		MARect rect = {0, 0, NUMCOLORS, 1};
		maGetImageData(ARGB_PNG, colors2, &rect, NUMCOLORS);

		assert("image: getData from PNG",
			(memcmp(sColors, colors2, sizeof(sColors)) == 0)
		);
		maDrawImage(ARGB_PNG, 0, 0);
		maUpdateScreen();
		//FREEZE;
	}
Exemple #9
0
void FeatureSet::CollectFeaturesInView()
{
	m_vFeatInViews.clear();
	mapExtent::iterator itEnd = m_mapExtent.end();
	mapExtent::iterator it = m_mapExtent.begin();
	DWORD nCount = 0;
	UINT nPoint = 0;
	int nScaleExtent = 10000;
	if (m_eFeatureType == POLYGON_TYPE)
	{
		nScaleExtent = 100000;
	}
	for (; it != itEnd; ++it)
	{
		if (!m_worldExtent.Intersect(EXTENT(it->first, nScaleExtent)))
			continue;
		m_vFeatInViews.push_back(it);
	}
}
Exemple #10
0
	void Label::calcStrSize() {
		mustCalcStrSize = false;
		Rect tempRect = Rect(0, 0, paddedBounds.width, paddedBounds.height);
		if(!font) {
			strSize = EXTENT(0,0);
		} else {
			if(autoSizeX)
				strSize = font->getStringDimensions(caption.c_str());
			else {
				if(multiLine) {	
					strSize = font->getBoundedStringDimensions(caption.c_str(), tempRect);
				} else {
					cutText(cuttedCaption, font, caption, tempRect);
					strSize = font->getStringDimensions(cuttedCaption.c_str());
				}
			}

		}
		strWidth  = EXTENT_X(strSize);
		strHeight = EXTENT_Y(strSize);

		if(autoSizeX) resize(strWidth + paddingLeft + paddingRight, bounds.height);
		if(autoSizeY) resize(bounds.width,  strHeight + paddingTop + paddingBottom);
	}
Exemple #11
0
MAExtent maGetStringExtents(MAHandle font, const char *str) {
	MAFont* f = &fonts[font];
	return EXTENT(f->charWidth*strlen(str), f->charHeight);
}
Exemple #12
0
EXTENT FeatureSet::GetFeatureExtent(size_t idx)
{
	Feature feat = m_vFeatures[idx];
	if (m_eFeatureType == POINT_TYPE)
	{
		int nX = m_pPoints[feat.nCoordOffset];
		int nY = m_pPoints[feat.nCoordOffset + 1];
		EXTENT oldExtent = g_MapManager.GetWorldExtent();
		double scale = (double)oldExtent.Height() / oldExtent.Width();
		return EXTENT(nX + 1200, nX - 1200, nY + 1200 * scale, nY - 1200 * scale);
	}
	else
	{
		std::vector<size_t> vFeatureIdx;
		vFeatureIdx.push_back(idx);
		size_t nFeatIdx = vFeatureIdx[0];
		Feature feat = m_vFeatures[nFeatIdx];
		while (true)
		{
			Feature featNext = m_vFeatures[++nFeatIdx];
			if (featNext.nAttributeOffset == feat.nAttributeOffset)
				vFeatureIdx.push_back(nFeatIdx);
			else
				break;
		}
		nFeatIdx = vFeatureIdx[0];
		while (true)
		{
			if (nFeatIdx == 0)
				break;
			Feature featNext = m_vFeatures[--nFeatIdx];
			if (featNext.nAttributeOffset == feat.nAttributeOffset)
				vFeatureIdx.push_back(nFeatIdx);
			else
				break;
		}

		EXTENT extent;
		for (UINT i = 0; i < vFeatureIdx.size(); ++i)
		{
			DWORD32 nCoordSize = 0;
			size_t nFeatIdx = vFeatureIdx[i];
			Feature feature = m_vFeatures[nFeatIdx];
			nCoordSize = m_vFeatures[nFeatIdx + 1].nCoordOffset - feature.nCoordOffset;
			UINT iStartPos = feature.nCoordOffset;
			UINT nRead = 0;
			while (nRead < nCoordSize)
			{
				int nX = m_pPoints[iStartPos++];
				if (nX < extent.xmin) extent.xmin = nX;
				if (nX > extent.xmax) extent.xmax = nX;
				
				int nY = m_pPoints[iStartPos++];
				if (nY < extent.ymin) extent.ymin = nY;
				if (nY > extent.ymax) extent.ymax = nY;
				nRead += 2;
			}
		}
		return extent * 3;
	}

	return m_worldExtent;
}
Exemple #13
0
bool FeatureSet::NextFeaturesPoints(size_t nFeatureNum,  
									std::vector<int>& vPoints,
									std::vector<UINT>& vPtNum
									)
{
	if (m_iterCurExent == m_mapExtent.end())
	{
		m_iterCurExent = m_mapExtent.begin();
		return false;
	}
	
	double scale = ((double)m_worldExtent.Width()) / m_oriExtent.Width();

	int worldX = m_worldExtent.xmin;
	int worldY = m_worldExtent.ymax;
	int worldWidth = m_worldExtent.Width();
	int worldHeight = m_worldExtent.Height();

	double x_scale = (double) m_viewRect.Width() / worldWidth;
	double y_scale = (double) m_viewRect.Height() / worldHeight;

	DWORD32 nAllFeature = 0;
	mapExtent::iterator itEnd = m_mapExtent.end(); 
	mapExtent::iterator it = m_iterCurExent;
	UINT nPoint = 0;
	int nScaleExtent = 10000;
	if (m_eFeatureType == POLYGON_TYPE)
	{
		nScaleExtent = 100000;
	}

	for (; it != itEnd; ++it)
	{
		if (!m_worldExtent.Intersect(EXTENT(it->first, nScaleExtent)))
			continue;

		int nSkipFeat = 0;
		if (scale > 0.4 && it->second.size() > 50 && m_nAllCoordsNum > 5000000)
		{
			nSkipFeat = 1;
		}
		if (scale > 0.4 && it->second.size() > 200 && m_nAllCoordsNum > 5000000)
		{
			nSkipFeat = 3;
		}
		if (scale > 0.3 && it->second.size() > 50 && m_nAllCoordsNum > 7500000)
		{
			nSkipFeat = 8;
		}
		if (scale > 0.3 && it->second.size() > 500 && m_nAllCoordsNum > 7500000)
		{
			nSkipFeat = 20;
		}
		if (scale > 0.3 && it->second.size() > 1000 && m_nAllCoordsNum > 7500000)
		{
			nSkipFeat = 40;
		}
		if (scale > 0.3 && it->second.size() > 5000 && m_nAllCoordsNum > 7500000)
		{
			nSkipFeat = 80;
		}
		std::vector<DWORD32>& vFeatureNum = it->second;
		DWORD32 nSize = vFeatureNum.size();
		for (DWORD32 i = m_nStartPos; i < nSize; ++i)
		{
			DWORD32 nFNum = vFeatureNum[i];
			Feature feature = m_vFeatures[nFNum];
			UINT nCoordSize = m_vFeatures[nFNum+1].nCoordOffset - feature.nCoordOffset;

			UINT iStartPos = feature.nCoordOffset;
			// First point
			int curX = (int)((m_pPoints[iStartPos++] - worldX) * x_scale);
			int curY = (int)((worldY - m_pPoints[iStartPos++]) * y_scale);
			vPoints.push_back(curX);
			vPoints.push_back(curY);
			nCoordSize -= 2;

			int nActualPoints = 1;
			while (nCoordSize)
			{
				int preX = curX;
				int preY = curY;
				curX = (int)((m_pPoints[iStartPos++] - worldX) * x_scale);
				curY = (int)((worldY - m_pPoints[iStartPos++]) * y_scale);
				nCoordSize -= 2;

				if (curX != preX || curY != preY)
				{
					++nActualPoints;
					vPoints.push_back(curX);
					vPoints.push_back(curY);
				}
			}

			if (nActualPoints == 1 && m_eFeatureType != POINT_TYPE)
			{
				vPoints.pop_back();
				vPoints.pop_back();
			}
			else
			{
				vPtNum.push_back(nActualPoints);
			}

			if (++nAllFeature == nFeatureNum)
			{
				m_nStartPos = ++i;
				m_iterCurExent = it;
				break;
			}
			i += nSkipFeat;
			m_nStartPos = 0;
		}

		if (nAllFeature == nFeatureNum)
		{
			if (m_nStartPos == nSize)
			{
				m_nStartPos = 0;
			}
			break;
		}
	}

	if (it == itEnd)
	{
		m_iterCurExent = it;
	}

	if (vPtNum.size() == 0)
		return false;

	if (m_eFeatureType == POINT_TYPE)
	{
		std::set<POINT> setPoint;
		size_t nCoords = vPoints.size() / 2;
		POINT* pPoints = (POINT*)(void*)&vPoints.front();
		for (UINT i = 0; i < nCoords; ++i)
		{
			setPoint.insert(pPoints[i]);
		}
		vPoints.clear();
		int nPreX = setPoint.begin()->x;
		int nPreY = setPoint.begin()->y;
		vPoints.push_back(nPreX);
		vPoints.push_back(nPreY);
		for (std::set<POINT>::const_iterator it = setPoint.begin(); it != setPoint.end(); ++it)
		{
			int nX = it->x;
			int nY = it->y;
			if (abs(nX - nPreX) > 5 || abs(nY - nPreY) > 5)
			{
				vPoints.push_back(nX);
				vPoints.push_back(nY);
			}
			nPreX = nX;
			nPreY = nY;
		}
		vPtNum.assign(vPoints.size() / 2, 1);
	}
	return true;
}
Exemple #14
0
bool FeatureSet::SelectFeatures(EXTENT& extent, int xScreen, int yScreen, bool bHit, bool bCtrl)
{
	const int xPos = extent.xmax - 3500;
	const int yPos = extent.ymax - 3500;

	int worldX = m_worldExtent.xmin;
	int worldY = m_worldExtent.ymax;
	int worldWidth = m_worldExtent.Width();
	int worldHeight = m_worldExtent.Height();

	double x_scale = (double) m_viewRect.Width() / worldWidth;
	double y_scale = (double) m_viewRect.Height() / worldHeight;

	if (!bCtrl)
		m_vFeatSelected.clear();
	int nScaleExtent = 10000;
	if (m_eFeatureType == POLYGON_TYPE)
	{
		nScaleExtent = 100000;
	}
	bool bFind = false;
	size_t nSaveFeat = 0;
	UINT distance = std::numeric_limits<UINT>::max();
	for (UINT i = 0; i < m_vFeatInViews.size(); ++i)
	{
		mapExtent::iterator it = m_vFeatInViews[i];
		if (!extent.Intersect(EXTENT(it->first, nScaleExtent)))
			continue;
		std::vector<DWORD32>& vFeatureNum = it->second;
		DWORD32 nSize = vFeatureNum.size();
		for (DWORD32 i = 0; i < nSize; ++i)
		{
			DWORD32 nCoordSize = 0;
			DWORD32 nFNum = vFeatureNum[i];
			Feature feature = m_vFeatures[nFNum];

			nCoordSize = m_vFeatures[nFNum+1].nCoordOffset - feature.nCoordOffset;

			UINT iStartPos = feature.nCoordOffset;	

			UINT nRead = 0;
			int nActualCoords = 0;
			bool bEven = true;
			int curX = 0;
			int curY = 0;
			int preX = 0;
			int preY = 0;
			int polySides = nCoordSize / 2;
			int* polyY = NULL;
			int* polyX = NULL;
			UINT polygonSize = 0;
			if (m_eFeatureType == POLYGON_TYPE)
			{
				polyY = (int*)malloc(polySides * sizeof(int));
				polyX = (int*)malloc(polySides * sizeof(int));
			}
			while (nRead < nCoordSize)
			{
				if (bEven)
				{
					bEven = !bEven;
					curX = m_pPoints[iStartPos++];
				}
				else
				{
					bEven = !bEven;
					curY = m_pPoints[iStartPos++];
				}
				++nRead;
				if (nRead % 2 == 0)
				{
					if (nRead == 2)
					{
						preX = curX;
						preY = curY;
					}

					if (m_eFeatureType == POINT_TYPE)
					{
						if (!bHit && extent.Include(CPoint(curX, curY)))
						{
							m_vFeatSelected.push_back(nFNum);
							break;
						}
						else if (bHit)
						{
							int scurX = (int)((curX - worldX) * x_scale);
							int scurY = (int)((worldY - curY) * y_scale);
							UINT nDist = (scurX - xScreen) * (scurX - xScreen) + (scurY - yScreen) * (scurY - yScreen);
							if (nDist > 3000)
								continue;
							if (nDist < distance)
							{
								distance = nDist;
								nSaveFeat = nFNum;
								bFind = true;
							}
						}
					}
					else if (nRead > 2 && m_eFeatureType == POLYLINE_TYPE)
					{
						int minX;
						int minY;
						int maxY, maxX;
						if (curX > preX)
						{
							minX = preX;
							maxX = curX;
						}
						else
						{
							minX = curX;
							maxX = preX;
						}

						if (curY > preY)
						{
							minY = preY;
							maxY = curY;
						}
						else
						{
							minY = curY;
							maxY = preY;
						}

						int nOffsetY = 160;
						int nOffsetX = 160;
						if (maxX - minX < 30)
						{
							nOffsetX = 600;
						}
						if (maxY - minY < 30)
						{
							nOffsetY = 600;
						}
						EXTENT tempExtent(maxX, minX, maxY, minY);
						if (!bHit && extent.Intersect(tempExtent))
						{
							m_vFeatSelected.push_back(nFNum);
							break;
						}
						else if (bHit && xPos <= (maxX+nOffsetX) && xPos >= (minX-nOffsetX) && yPos <= (maxY+nOffsetY) && yPos >= (minY-nOffsetY))
						{
							double l = DistancePtToPt(curX, curY, preX, preY);
							UINT nDist = 0;
							if (fabs(l - 0.0) < 0.01)
							{
								nDist = DistancePtToPt(curX, curY, xPos, yPos);
							}
							else
							{
								double r = ((curY - yPos)*(curY - preY) - (curX - xPos)*(preX - curX))/(l*l);
								if(r > 1 || r < 0) /* perpendicular projection of P is on the forward extention of AB */
								{
									nDist = min(DistancePtToPt(xPos, yPos, preX, preY), DistancePtToPt(xPos, yPos, curX, curY));
								}
								else
								{
								   double s = ((curY - yPos)*(preX - curX) - (curX - xPos)*(preY - curY))/(l*l);
								   nDist = fabs(s*l);
								}
							}
							if (nDist < distance)
							{
								distance = nDist;
								nSaveFeat = nFNum;
								bFind = true;
							}
						}
						preX = curX;
						preY = curY;
					}
					else if (m_eFeatureType == POLYGON_TYPE)
					{
						if (bHit)
						{
							polyY[polygonSize] = curY;
							polyX[polygonSize++] = curX;
						}
						else
						{
							int minX;
							int minY;
							int maxY, maxX;
							if (curX > preX)
							{
								minX = preX;
								maxX = curX;
							}
							else
							{
								minX = curX;
								maxX = preX;
							}

							if (curY > preY)
							{
								minY = preY;
								maxY = curY;
							}
							else
							{
								minY = curY;
								maxY = preY;
							}
							EXTENT tempExtent(maxX, minX, maxY, minY);
							if (extent.Intersect(tempExtent))
							{
								m_vFeatSelected.push_back(nFNum);
								break;
							}
							preX = curX;
							preY = curY;
						}
					}
				}
			}

			if (bHit && m_eFeatureType == POLYGON_TYPE)
			{
				int   i, j= polySides- 1;
				bool  oddNodes=false;

				for (i=0; i<polySides; i++) {
				if ((polyY[i]< yPos && polyY[j]>= yPos
				||   polyY[j]< yPos && polyY[i]>=yPos)
				&&  (polyX[i]<=xPos || polyX[j]<=xPos)) {
					oddNodes^=(polyX[i]+(yPos-polyY[i])/(polyY[j]-polyY[i])*(polyX[j]-polyX[i])<xPos); }
				j=i; }
				free(polyX);
				free(polyY);
				if (oddNodes)
				{
					m_vFeatSelected.push_back(nFNum);
					return true;
				}
			}
		}
	}
	if (m_eFeatureType != POLYGON_TYPE && bHit && bFind)
	{
		if (m_eFeatureType == POLYLINE_TYPE && distance > 1000)
		{
			return true;
		}
		//if (m_eFeatureType == POLYLINE_TYPE && distance > 3000)
		//{
		//    return true;
		//}
		std::vector<UINT>::iterator it = std::find(m_vFeatSelected.begin(), m_vFeatSelected.end(), nSaveFeat);
		if (it != m_vFeatSelected.end())
		{
			m_vFeatSelected.erase(it);
		}
		else
		{
			m_vFeatSelected.push_back(nSaveFeat);
		}
	}
	std::sort(m_vFeatSelected.begin(), m_vFeatSelected.end());
	m_vFeatSelected.erase(std::unique(m_vFeatSelected.begin(), m_vFeatSelected.end()), m_vFeatSelected.end());
	return true;
}
Exemple #15
0
	// HACK: We postpone line feeds at very end of output to avoid having a
	// (usually) empty line at the bottom of the (admittedly tiny) display
	// This flag indicates whether or not such a line feed was postponed during
	// the last output call
	// If this hack makes you cry, feel free to remove it
	int postponedLineFeed;
	// The size of the screen, in pixels
	MAExtent screenSize;
	// The line (y) and column (x) position of the cursor
	MAPoint2d cursorPos;
	// The text line ring buffer
	ConLine* lines;
} ConData;

// Private data for the console
static ConData sConsole = { 0, 0, 0, 0, 0, EXTENT(0, 0), { 0, 0 }, NULL };

// These are global variables documented in conprint.h
int gConsoleTextColor = 0x00FF00;	//green
int gConsoleBackgroundColor = 0;	//black
int gConsoleLogging = 1;
MAHandle gConsoleFile = 0;
int gConsoleDisplay = 1;

int gConsoleDrawBackground = 1;
int gConsoleForceDisplay = 1;


static void FeedLine(void)
{
	sConsole.cursorPos.y++;