Beispiel #1
0
void copyConstructor1() {
	Length_m len1(7);
	Length_m len2 = len1;
	assert(len2.value == 7);

	Area_m2 area1(7);
	Area_m2 area2 = area1;
	assert(area2.value == 7);
}
Beispiel #2
0
void fractal::draw_border( bool is_active ) {
    color_t color = is_active ? v->get_color(0, 255, 0) // green color
                                : v->get_color(96, 128, 96); // green-gray color

    // top border
    drawing_area area0( off_x-1, off_y-1, size_x+2, 1, dm );
    for (int i=-1; i<size_x+1; ++i)
        area0.put_pixel(color);
    // bottom border
    drawing_area area1( off_x-1, off_y+size_y, size_x+2, 1, dm );
    for (int i=-1; i<size_x+1; ++i)
        area1.put_pixel(color);
    // left border
    drawing_area area2( off_x-1, off_y, 1, size_y+2, dm );
    for (int i=0; i<size_y; ++i)
        area2.set_pixel(0, i, color);
    // right border
    drawing_area area3( size_x+off_x, off_y, 1, size_y+2, dm );
    for (int i=0; i<size_y; ++i)
        area3.set_pixel(0, i, color);
}
Beispiel #3
0
int compare( const void *arg1, const void *arg2 )
{
	try {

		const I_MapItem *i1 = *reinterpret_cast<I_MapItem**>(const_cast<void*>(arg1));
		const I_MapItem *i2 = *reinterpret_cast<I_MapItem**>(const_cast<void*>(arg2));

		C_TextPtr text1(const_cast<I_MapItem*>(i1));
		C_TextPtr text2(const_cast<I_MapItem*>(i2));

		if (text1 && !text2) {
			return 1;
		}
		else if (text2 && !text1) {
			return -1;
		}

		C_PicturePtr pic1(const_cast<I_MapItem*>(i1));
		C_PicturePtr pic2(const_cast<I_MapItem*>(i2));

		if (pic1 && !pic2) {
			return 1;
		}
		else if (pic2 && !pic1) {
			return -1;
		}

		C_PositionPtr p1(const_cast<I_MapItem*>(i1));
		C_PositionPtr p2(const_cast<I_MapItem*>(i2));

		if (p1 && p2) {

			C_Area area1(p1.GetPoints());
			C_Area area2(p2.GetPoints());

			int n = 0;
			int cnt1 = area1.GetLength();
			int cnt2 = area2.GetLength();

			if (0 == cnt1) {
				return -1;
			}

			if (0 == cnt2) {
				return 1;
			}

			POINT3D *ptr1 = area1[cnt1 - 1];
			POINT3D *ptr2 = area2[cnt2 - 1];

			if (ptr1->x < 0 && ptr2->x > 0) {
				n = -1;
			}
			else if (ptr1->x > 0 && ptr2->x < 0) {
				n = 1;
			}
			else if (ptr1->y < ptr2->y) {
				n = -1;
			}
			else if (ptr1->y > ptr2->y) {
				n = 1;
			}

			if (0 == n) {

				if (cnt1 < cnt2) {
					n = -1;
				}
				else if (cnt1 > cnt2) {
					n = 1;
				}
			}

			if (0 != n) {
				return n;
			}
		}

		C_UniquePtr u1(const_cast<I_MapItem*>(i1));
		C_UniquePtr u2(const_cast<I_MapItem*>(i2));

		if (!u1 && !u2) {
			return 0;
		}
		else if (!u1) {
			return -1;
		}
		else if (!u2) {
			return 1;
		}
		else {

			BSTR bs1 = NULL;
			BSTR bs2 = NULL;

			u1->get_UID(&bs1);
			u2->get_UID(&bs2);

			int n = ::wcscmp(bs1, bs2);

			String::FreeBSTR(&bs1);
			String::FreeBSTR(&bs2);

			return n;
		}
	}
	catch (C_STLNonStackException const &exception) {
		exception.Log(_T("Exception in Items.cpp (compare)"));
	}

	return 0;
}