void CLuaGroup::AddLuaWidget(CLuaWidget *w)
{
    if (m_bInitEnable)
    {
        m_bInitEnable = false;
        Enable(true);
    }
    
    // Update each widget's max size, this is necessary before adding new widget because they
    // may request too much width
    const TWidgetList &list = GetWidgetList();
    const int size = SafeConvert<int>(list.size()) + 1; // +1 because new widget is not added yet
    const int maxwidgetsw = NNCurses::GetMaxWidth() - 6;
    const int maxwidth = (maxwidgetsw - (LuaWidgetSpacing() * (size-1))) / size;
    for (TWidgetList::const_iterator it=list.begin(); it!=list.end(); it++)
    {
        CLuaWidget *luaw = dynamic_cast<CLuaWidget *>(*it);
        if (luaw)
            luaw->SetMaxWidth(maxwidth);
    }

    CBox *box = new CBox(VERTICAL, false);
    box->StartPack(w, true, false, 0, 0);
    w->SetMaxWidth(maxwidth);

    StartPack(box, true, true, 0, 0);
}
示例#2
0
void CPedModelInfo::CreateHitColModelSkinned(RpClump* clump)
{
	RpHAnimHierarchy* hier = GetAnimHierarchyFromSkinClump(clump);
	CColModel* hitColModel = new CColModel;
	RwMatrixTag* frameInverseMat = CGame::GetWorkingMatrix1();
	RwMatrixTag* transformMatrix = CGame::GetWorkingMatrix2();
	hitColModel->AllocateData(12, 0, 0, 0, 0, 0);
	RwMatrixInvert(frameInverseMat, &RpClumpGetFrame(clump)->modelling);
	for (size_t i = 0; i < ELEMS_COUNT(m_pColNodeInfos); i++)
	{
		CColSphere colSphere;
		colSphere.Set(m_pColNodeInfos[i].sphere.GetRadius(), m_pColNodeInfos[i].sphere.GetCenter());
		CCollisionData* colData = hitColModel->GetColData();
		*transformMatrix = *frameInverseMat;
		RwInt32 matIndex = RpHAnimIDGetIndex(hier, m_pColNodeInfos[i].animId) << 6;
		RwMatrix* mat = (RwMatrix*)(RpHAnimHierarchyGetMatrixArray(hier) + matIndex);
		RwMatrixTransform((RwMatrix *)transformMatrix, mat, rwCOMBINEPRECONCAT);
		RwV3dTransformPoints(&colSphere.center, &colSphere.center, 1, (RwMatrix *)transformMatrix);
		colSphere.SetSurfaceTypeA(EColSurface::PED);
		colSphere.SetSurfaceTypeB(m_pColNodeInfos[i].surfaceTypeB);
		colData->SetSphere(i, colSphere);
	}
	CBoundingBox boundingBox;
	CVector maxbb(0.5f, 0.5f, 1.2f);
	CVector minbb(-0.5f,-0.5f,-1.2f);
	CBox box;
	box.Set(minbb, maxbb);
	boundingBox.SetBoundingSphere(CSphere(0, 0, 0, 1.5f));
	hitColModel->SetBoundingBox(boundingBox);
	hitColModel->SetColNum(0);
	m_hitColModel = hitColModel;
}
示例#3
0
String^ CommandLine::Text::get()
{
	CBox box;
	while(box(Info.PanelControl(INVALID_HANDLE_VALUE, FCTL_GETCMDLINE, box.Size(), box))) {}
	
	return gcnew String(box);
}
示例#4
0
文件: CBox.cpp 项目: joyfish/PlaneWar
CBox * CBox::create() {
    CBox * pRet = NEW CBox();
    if (pRet) {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return NULL;
}
示例#5
0
	void Run()
	{
		CBox box;
		sketch_for_tools->GetBox(box);
		double centre[3];
		box.Centre(centre);		

		wxGetApp().m_digitizing->digitized_point = DigitizedPoint(gp_Pnt(box.MinX(), centre[1], centre[2]), DigitizeInputType);
		Drawing *pDrawingMode = dynamic_cast<Drawing *>(wxGetApp().input_mode_object);
		if (pDrawingMode != NULL)
		{
			pDrawingMode->AddPoint();
		}
	}
void CButtonBar::PushLabel(const std::string &n, const std::string &d)
{
    CBox *lbox = new CBox(HORIZONTAL, false);
    
    CLabel *label = new CLabel(n + ": ");
    label->SetDFColors(GetFColors());
    lbox->StartPack(label, false, false, 0, 0);
    
    label = new CLabel(d);
    label->SetDFColors(GetDFColors());
    lbox->StartPack(label, false, false, 0, 0);

    m_pCurBox->StartPack(lbox, true, false, 0, 0);
}
示例#7
0
void GetGridBox(const CViewPoint *view_point, CBox &ext){
	gp_Pnt sp[4];
	double zval = 0.5;
	wxSize size = wxGetApp().m_current_viewport->GetViewportSize();
	sp[0] = gp_Pnt(0, 0, zval);
	sp[1] = gp_Pnt(size.GetWidth(), 0, zval);
	sp[2] = gp_Pnt(size.GetWidth(), size.GetHeight(), zval);
	sp[3] = gp_Pnt(0, size.GetHeight(), zval);
	gp_Vec vx, vy;
	view_point->GetTwoAxes(vx, vy, false, 0);
	gp_Pnt datum(0, 0, 0);
	gp_Trsf orimat = wxGetApp().GetDrawMatrix(false);
	datum.Transform(orimat);
	orimat = make_matrix(datum, vx, vy);
	gp_Pln plane(datum, gp_Vec(0, 0, 1).Transformed(orimat));
	{
		for(int i =0; i<4; i++){
			gp_Pnt p1 = view_point->glUnproject(sp[i]);
			sp[i].SetZ(0);
			gp_Pnt p2 = view_point->glUnproject(sp[i]);
			gp_Lin line = make_line(p1, p2);
			gp_Pnt pnt;
			if(intersect(line, plane, pnt))
			{
				ext.Insert(pnt.X(), pnt.Y(), pnt.Z());
			}
		}
	}
}
示例#8
0
int main()
{
    CBox smallBox(4.0, 2.0, 1.0);
    CBox mediumBox(10.0, 4.0, 2.0);
    CBox aBox;
    CBox bBox;

    aBox = smallBox + mediumBox;
    cout << "aBox dimensions are ";
    aBox.ShowBox();

    bBox = aBox + smallBox + mediumBox;
    cout << "bBox dimensions are ";
    bBox.ShowBox();

    return 0;
}
示例#9
0
文件: Simulate.cpp 项目: play113/swer
static void	WriteSolids(std::wofstream &ofs)
{

	std::set<int> stock_ids;
	wxGetApp().m_program->Stocks()->GetSolidIds(stock_ids);
	for(std::set<int>::iterator It = stock_ids.begin(); It != stock_ids.end(); It++)
	{
		int id = *It;
		HeeksObj* object = wxGetApp().GetIDObject(SolidType, id);
		if(object)
		{
			CBox box;
			object->GetBox(box);
			ofs<<"voxelcut.set_current_color("<<object->GetColor()->COLORREF_color()<<")\n";
			double c[3];
			box.Centre(c);
			ofs<<"toolpath.coords.add_block("<<c[0]<<", "<<c[1]<<", "<<box.MinZ()<<", "<<box.Width()<<", "<<box.Height()<<", "<<box.Depth()<<")\n";
		}
	}
}
示例#10
0
void HRuler::GetBox(CBox &box)
{
	gp_Pnt point[4];
	GetFourCorners(point);

	for(int i = 0; i<4; i++)
	{
		point[i].Transform(m_trsf);
		box.Insert(point[i].X(), point[i].Y(), point[i].Z());
	}
}
示例#11
0
文件: Edge.cpp 项目: Heeks/heekscad
void CEdge::GetBox(CBox &box){
	// just use the vertices for speed
	for (TopExp_Explorer expVertex(m_topods_edge, TopAbs_VERTEX); expVertex.More(); expVertex.Next())
	{
		const TopoDS_Shape &V = expVertex.Current();
		gp_Pnt pos = BRep_Tool::Pnt(TopoDS::Vertex(V));
		double p[3];
		extract(pos, p);
		box.Insert(p);
	}
}
示例#12
0
void CShape::GetBox(CBox &box)
{
	if(!m_box.m_valid)
	{
		if(m_faces == NULL)create_faces_and_edges();
		BRepTools::Clean(m_shape);
		BRepMesh::Mesh(m_shape, 1.0);
		if(m_faces)m_faces->GetBox(m_box);
	}

	box.Insert(m_box);
}
示例#13
0
const bool	CBox::Contains(const CBox& Box) const {
    return Box.GetXLower() >= this->GetXLower() &&
           Box.GetXHigher() <= this->GetXHigher() &&
           Box.GetYLower() >= this->GetYLower() &&
           Box.GetYHigher() <= this->GetYHigher() &&
           Box.GetZLower() >= this->GetZLower() &&
           Box.GetZHigher() <= this->GetZHigher();
}
示例#14
0
文件: HGear.cpp 项目: play113/swer
void HGear::GetBox(CBox &box){
	double acting_radius = (double)(m_module * m_num_teeth)/2;
	double outside_radius = acting_radius + (m_addendum_multiplier*m_module + m_addendum_offset);
	gp_Trsf mat = make_matrix(m_pos.Location(), m_pos.XDirection(), m_pos.YDirection());
	gp_Pnt p[4];
	p[0] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(outside_radius, outside_radius, 0.0));
	p[1] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(-outside_radius, outside_radius, 0.0));
	p[2] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(-outside_radius, -outside_radius, 0.0));
	p[3] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(outside_radius, -outside_radius, 0.0));
	for(int i = 0; i<4; i++)
	{
		p[i].Transform(mat);
		box.Insert(p[i].X(), p[i].Y(), p[i].Z());
	}
}
示例#15
0
void HDimension::GetBox(CBox &box)
{
	gp_Pnt vt(0, 0, 0);
	vt.Transform(m_trsf);
	double p[3];
	extract(vt, p);
	box.Insert(p);

	wxString text = MakeText();
	float width, height;
	if(!wxGetApp().get_text_size(text, &width, &height))return;

	gp_Pnt point[3];
	point[0] = gp_Pnt(width, 0, 0);
	point[1] = gp_Pnt(0, -height, 0);
	point[2] = gp_Pnt(width, -height, 0);

	for(int i = 0; i<3; i++)
	{
		point[i].Transform(m_trsf);
		extract(point[i], p);
		box.Insert(p);
	}
}
示例#16
0
void CFace::GetBox(CBox &box){
//	if(!m_box.m_valid)
	{
		// there must be a better way than re-using the render code
		// Get triangulation
		if(GetParentBody() == NULL){
			MeshFace(m_topods_face,.01);
		}

		FaceForBoxCallback = this;
		DrawFace(m_topods_face,box_callback,false);
	}

	box.Insert(m_box);
}
示例#17
0
/**
	Find out how high up all the objects are for this operation.   From this we
	will determine how far to retract the  tool so as not to hit
	them during rapid movements.
 */
double CAdaptive::GetMaxHeight( const int object_type, const std::list<int> & object_ids )
{
	// Look through the objects that make up the model and find a safe height.
	bool l_bValueUnset = true;
	double max_z = -999999;
	for (std::list<int>::const_iterator l_itObjectID = object_ids.begin(); l_itObjectID != object_ids.end(); l_itObjectID++)
	{
		HeeksObj *ob = heeksCAD->GetIDObject( object_type, *l_itObjectID );
		if (ob != NULL)
		{
			CBox bbox;
			ob->GetBox( bbox );
			{
				if ((l_bValueUnset) || (bbox.MaxZ() > max_z))
				{
					max_z = bbox.MaxZ();
					l_bValueUnset = false;
				} // End if - then
			} // End if - then
		} // End if - then
	} // End for

	return(max_z);
} // End GetMaxHeight() method
示例#18
0
void ObjList::GetBox(CBox &box)
{
	std::list<HeeksObj*>::iterator It;
	for(It=m_objects.begin(); It!=m_objects.end() ;It++)
	{
		HeeksObj* object = *It;
		if(object->OnVisibleLayer() && object->m_visible)
		{
		    if (It == m_objects.begin())
		    {
		        object->GetBox(box);
		    }
		    else
		    {
                CBox new_box;
                object->GetBox(new_box);
                box.Insert(new_box);
		    }
		}
	}
}
示例#19
0
文件: Simulate.cpp 项目: play113/swer
static void	WriteCoords(std::wofstream &ofs)
{
	CBox box;
	GetWorldBox(box);

	if(!box.m_valid)
	{
		box = CBox(-100, -100, -50, 100, 100, 50);
	}
	else
	{
		while(box.Width() < 100){box.m_x[0] -= 5.0; box.m_x[3] += 5.0;}
		while(box.Height() < 100){box.m_x[1] -= 5.0; box.m_x[4] += 5.0;}
		box.m_x[2] -= 10.0;
	}

	ofs<<"toolpath.coords = Coords("<<box.MinX()<<", "<<box.MinY()<<", "<<box.MinZ()<<", "<<box.MaxX()<<", "<<box.MaxY()<<", "<<box.MaxZ()<<")\n";
}
示例#20
0
 // Function to compare two boxes which returns true (1)
 // if the first is greater than the second, and false (0) otherwise
 int Compare(const CBox& xBox) const {
     return this->Volume() > xBox.Volume();
 }
// Function for testing if a constant is < CBox object
bool operator<(const double& value, const CBox& aBox)
{ return value < aBox.Volume(); }
// Operator function for 'greater than' that
// compares volumes of CBox objects.
bool CBox::operator>(const CBox& aBox) const
{
  return this->Volume() > aBox.Volume();
}
示例#23
0
void HLine::GetBox(CBox &box){
	box.Insert(A->m_p.X(), A->m_p.Y(), A->m_p.Z());
	box.Insert(B->m_p.X(), B->m_p.Y(), B->m_p.Z());
}
示例#24
0
文件: 源.cpp 项目: Hackergeek/C
inline bool operator > (const double& value, const CBox& aBox)
{
	return value > aBox.Volume();
}
示例#25
0
文件: 源.cpp 项目: Hackergeek/C
	bool operator == (const CBox& aBox) const
	{
		return this->Volume() == aBox.Volume();
	}
示例#26
0
文件: 源.cpp 项目: Hackergeek/C
	bool operator < (const CBox& aBox) const
	{
		return this->Volume() < aBox.Volume();
	}
// Operator to return the free volume in a packed CBox
double operator%( const CBox& aBox, const CBox& bBox)
{ return aBox.Volume() - (aBox / bBox) * bBox.Volume(); }
float CCollision::SweepAABB(CBox box1, CBox box2, CDirection &normalX, CDirection &normalY, float frameTime)
{
	float xInvEntry, yInvEntry;
	float xInvExit, yInvExit;

	if (box1.Velocity.x > 0.0f)
	{
		xInvEntry = box2.Position.x - (box1.Position.x + box1.Size.x);
		xInvExit = (box2.Position.x + box2.Size.x) - box1.Position.x;
	}
	else
	{
		xInvEntry = (box2.Position.x + box2.Size.x) - box1.Position.x;
		xInvExit = box2.Position.x - (box1.Position.x + box1.Size.x);
	}

	if (box1.Velocity.y > 0.0f)
	{
		yInvEntry = (box2.Position.y - box2.Size.y) - box1.Position.y;
		yInvExit = box2.Position.y - (box1.Position.y - box1.Size.y);
	}
	else
	{
		yInvEntry = box2.Position.y - (box1.Position.y - box1.Size.y);
		yInvExit = (box2.Position.y - box2.Size.y) - box1.Position.y;
	}

	float xEntry, xExit;
	float yEntry, yExit;

	if (box1.Velocity.x == 0.0f)
	{
		xEntry = -std::numeric_limits<float>::infinity();
		xExit = std::numeric_limits<float>::infinity();
	}
	else
	{
		xEntry = xInvEntry / box1.Velocity.x;
		xExit = xInvExit / box1.Velocity.x;
	}

	if (box1.Velocity.y == 0.0f)
	{
		yEntry = -std::numeric_limits<float>::infinity();
		yExit = std::numeric_limits<float>::infinity();
	}
	else
	{
		yEntry = yInvEntry / box1.Velocity.y;
		yExit = yInvExit / box1.Velocity.y;
	}

	float entryTime, exitTime;

	entryTime = __max(xEntry, yEntry);
	exitTime = __min(xExit, yExit);

#pragma region Xét va chạm với các trường hợp còn lại
	if (entryTime > exitTime || xEntry<0.0f&&yEntry<0.0f || xEntry>frameTime || yEntry>frameTime)
	{
		normalX = CDirection::NONE_DIRECT;
		normalY = CDirection::NONE_DIRECT;

		if (box1.IsIntersectedWith(box2))
		{
			if (fabsf(box1.Position.y - box1.Size.y - box2.Position.y) <= 2.0f
				&& !(box1.Position.x + box1.Size.x <= box2.Position.x || box1.Position.x >= box2.Position.x + box2.Size.x))
				normalY = CDirection::ON_DOWN;

			else if (fabsf(box1.Position.y - (box2.Position.y - box2.Size.y)) <= 2.0f
				&& !(box1.Position.x + box1.Size.x <= box2.Position.x || box1.Position.x >= box2.Position.x + box2.Size.x))
				normalY = CDirection::ON_UP;

			else if (fabsf(box1.Position.x + box1.Size.x - box2.Position.x) <= 2.0f
				&& !(box1.Position.y - box1.Size.y >= box2.Position.y || box1.Position.y <= box2.Position.y - box2.Size.y))
				normalX = CDirection::ON_RIGHT;

			else if (fabsf(box1.Position.x - (box2.Position.x + box2.Size.x)) <= 2.0f
				&& !(box1.Position.y - box1.Size.y >= box2.Position.y || box1.Position.y <= box2.Position.y - box2.Size.y))
				normalX = CDirection::ON_LEFT;

			else if (!(box1.Position.y - box1.Size.y >= box2.Position.y
				|| box1.Position.y <= box2.Position.y - box2.Size.y
				|| box1.Position.x + box1.Size.x <= box2.Position.x
				|| box1.Position.x >= box2.Position.x + box2.Size.x))
				normalX = normalY = CDirection::INSIDE;
		}
		return 0;
	}
#pragma  endregion
#pragma region Nếu có va chạm xảy ra
	else
	{
		if (xEntry > yEntry)
		{
			if (box1.Velocity.x > 0.0f)
			{
				if (!(box1.Position.y - box1.Size.y >= box2.Position.y || box1.Position.y <= box2.Position.y - box2.Size.y))
				{
					normalX = CDirection::ON_RIGHT;
					normalY = CDirection::NONE_DIRECT;
				}
				else
				{
					if (fabsf(box1.Position.y - box1.Size.y - box2.Position.y) <= 2.0f)
					{
						normalX = CDirection::NONE_DIRECT;
						normalY = CDirection::ON_DOWN;
						entryTime = 0.0f;
					}
					else if (fabsf(box1.Position.y - (box2.Position.y - box2.Size.y) <= 2.0f))
					{
						normalX = CDirection::NONE_DIRECT;
						normalY = CDirection::ON_UP;
						entryTime = 0.0f;
					}
				}
			}
			else
			{
				if (!(box1.Position.y - box1.Size.y >= box2.Position.y || box1.Position.y <= box2.Position.y - box2.Size.y))
				{
					normalX = CDirection::ON_LEFT;
					normalY = CDirection::NONE_DIRECT;
				}
				else
				{
					if (fabsf(box1.Position.y - box1.Size.y - box2.Position.y) <= 2.0f)
					{
						normalX = CDirection::NONE_DIRECT;
						normalY = CDirection::ON_DOWN;
						entryTime = 0.0f;
					}
					else if (fabsf(box1.Position.y - (box2.Position.y - box2.Size.y)) <= 2.0f)
					{
						normalX = CDirection::NONE_DIRECT;
						normalY = CDirection::ON_UP;
						entryTime = 0.0f;
					}
				}
			}
		}
		else
		{
			if (box1.Velocity.y > 0.0f)
			{
				if (!(box1.Position.x + box1.Size.x <= box2.Position.x || box1.Position.x >= box2.Position.x + box2.Size.x))
				{
					normalY = CDirection::ON_UP;
					normalX = CDirection::NONE_DIRECT;
				}
				else
				{
					if (fabsf(box1.Position.x + box1.Size.x - box2.Position.x) <= 2.0f)
					{
						normalY = CDirection::NONE_DIRECT;
						normalX = CDirection::ON_RIGHT;
						entryTime = 0.0f;
					}
					else if (fabsf(box1.Position.x - (box2.Position.x + box2.Size.x)) < 2.0f)
					{
						normalY = CDirection::NONE_DIRECT;
						normalX = CDirection::ON_LEFT;
						entryTime = 0.0f;
					}
				}
			}
			else
			{
				if (!(box1.Position.x + box1.Size.x <= box2.Position.x || box1.Position.x >= box2.Position.x + box2.Size.x))
				{
					normalY = CDirection::ON_DOWN;
					normalX = CDirection::NONE_DIRECT;
				}
				else
				{
					if (fabsf(box1.Position.x + box1.Size.x - box2.Position.x) <= 2.0f)
					{
						normalY = CDirection::NONE_DIRECT;
						normalX = CDirection::ON_RIGHT;
						entryTime = 0.0f;
					}
					else if (fabsf(box1.Position.x - (box2.Position.x + box2.Size.x)) < 2.0f)
					{
						normalY = CDirection::NONE_DIRECT;
						normalX = CDirection::ON_LEFT;
						entryTime = 0.0f;
					}
				}
			}
		}
		return entryTime;
	}
#pragma endregion
}
bool CCollision::AABBCheck(CBox box1, CBox box2)
{
	return box1.IsIntersectedWith(box2);
}
示例#30
0
void HImage::GetBox(CBox &box)
{
	for(int i = 0; i<4; i++)box.Insert(m_x[i]);
}