Exemple #1
0
void  SplineCommand::LeftClick(unsigned int nFlags,int pX,int pY)
{
	SWITCH_RESOURCE
	const unsigned int knC = m_geo->GetKnotsCount();
	if (knC==0)
	{
		m_geo->AddKnot(m_cur_pnt,0);
		m_first_point = m_cur_pnt;
		m_last_point  = m_cur_pnt;
		if (m_existing_points)
			m_existing_points->AddPoint(m_first_point);
		m_geo->AddKnot(m_cur_pnt,1);
	}
	else
	{
		if (m_geo->IsClosed())
		{
			sgCSpline* spl = sgCreateSpline(*m_geo);
			if (!spl)
			{
				SG_SPLINE::Delete(m_geo);
				m_geo = SG_SPLINE::Create();
				m_message.LoadString(IDS_CREARE_SPL_ERROR);
				m_app->PutMessage(IApplicationInterface::MT_ERROR,
					m_message);
				return;
			}
			CString nm;
			nm.LoadString(IDS_TOOLTIP_FOURTH);
			CString nmInd;
			nmInd.Format("%i",spline_name_index);
			nm+=nmInd;
			spl->SetName(nm.GetBuffer());
			sgGetScene()->StartUndoGroup();
			sgGetScene()->AttachObject(spl);
			m_app->ApplyAttributes(spl);
			sgGetScene()->EndUndoGroup();
			spline_name_index++;
			SG_SPLINE::Delete(m_geo);
			m_geo = SG_SPLINE::Create();
			if (m_existing_points)
				m_existing_points->RemoveAllPoints();
		}
		else
		{
			if (sgSpaceMath::PointsDistance(m_cur_pnt,m_last_point)<0.001)
			{
				m_message.LoadString(IDS_ERROR_SPL_KNOT_AS_PREV);
				m_app->PutMessage(IApplicationInterface::MT_ERROR,
					m_message);
				return;
			}
            m_geo->AddKnot(m_cur_pnt,knC);
			m_last_point = m_cur_pnt;
			if (m_existing_points)
				m_existing_points->AddPoint(m_cur_pnt);
		}
	}
	m_app->GetViewPort()->InvalidateViewPort();
}
void  CNuGenDimensionView::DrawScene(GLenum mode, bool selSubObj)
{
    sgCObject*  curObj = sgGetScene()->GetObjectsList()->GetHead();
    while (curObj)
    {
        if (/*sgGetScene()->GetLayerVisible(curObj->GetAttribute(SG_OA_LAYER))*/true)
        {
            Drawer::DrawObject(mode,curObj,selSubObj);

            if ((curObj->GetAttribute(SG_OA_DRAW_STATE) & SG_DS_GABARITE) &&
                    curObj!=Drawer::CurrentEditableObject)
            {
                SG_POINT a1,a2;
                curObj->GetGabarits(a1,a2);
                Drawer::DrawGabariteBox(a1,a2,Drawer::HotObjectColor);
            }

            /*if (curObj->GetType()==SG_OT_3D)
            {
            	sgC3DObject* ooo = reinterpret_cast<sgC3DObject*>(curObj);
            	for (unsigned int i=0;i<ooo->GetBRep()->GetPiecesCount();i++)
            	{
            		SG_POINT s1,s2;
            		ooo->GetBRep()->GetPiece(i)->GetLocalGabarits(s1,s2);
            		Drawer::DrawGabariteBox(s1,s2,Drawer::HotObjectColor);
            	}
            }*/
        }
        curObj = sgGetScene()->GetObjectsList()->GetNext(curObj);
    }
    /*SG_POINT s1,s2;
    sgGetScene()->GetGabarits(s1,s2);
    Drawer::DrawGabariteBox(s1,s2,Drawer::HotObjectColor);*/
}
void OnBnClickedPrBoxes()
{
  sgGetScene()->Clear();

  AddFloorInScene(7.0, 7.0, 1.0, 1.0, -0.3);

  sgCBox* bx1 = sgCreateBox(1,2,2.1);

  SG_VECTOR transV = {-5,-5,0};
 /* bx1->InitTempMatrix()->Translate(transV);
  bx1->ApplyTempMatrix();
  bx1->DestroyTempMatrix();*/

  sgGetScene()->AttachObject(bx1);
  bx1->SetAttribute(SG_OA_COLOR,8);

  //SetMaterialToObject(bx1,MATERIAL_IMAGE_1);

  sgCBox* bx2 = sgCreateBox(1,1,1);

  transV.x = 1.5;
  transV.y = 0.0;
  transV.z = 0.0;
  bx2->InitTempMatrix()->Translate(transV);
  bx2->ApplyTempMatrix();
  bx2->DestroyTempMatrix();

  //SetMaterialToObject(bx2,MATERIAL_GLASS_4);

  sgGetScene()->AttachObject(bx2);
  bx2->SetAttribute(SG_OA_COLOR,0);
  bx2->SetAttribute(SG_OA_LINE_THICKNESS,1);
  bx2->SetAttribute(SG_OA_LINE_TYPE,1);
}
void OnBnClickedPrEquidi()
{
  sgCObject* curObj = sgGetScene()->GetObjectsList()->GetHead();
  std::vector<sgC2DObject*>   good_objcts;
  int i=0;
  while (curObj)
  {
    SG_OBJECT_TYPE ot = curObj->GetType();
    if (ot==SG_OT_CIRCLE ||ot==SG_OT_ARC || ot==SG_OT_SPLINE || ot==SG_OT_CONTOUR)
    {
      sgC2DObject* o2D = reinterpret_cast<sgC2DObject*>(curObj);
      if (!o2D->IsLinear() && o2D->IsPlane(NULL,NULL))
        good_objcts.push_back(o2D);
    }
    curObj = sgGetScene()->GetObjectsList()->GetNext(curObj);
 }

  size_t sz = good_objcts.size();
  for (size_t i=0;i<sz;i++)
  {
    sgCContour* eq1 = good_objcts[i]->GetEquidistantContour(0.3, 0.3, false);
    if (eq1)
      sgGetScene()->AttachObject(eq1);
    sgCContour* eq2 = good_objcts[i]->GetEquidistantContour(-0.3, -0.3, false);
    if (eq2)
      sgGetScene()->AttachObject(eq2);
  }
}
void  TextEditCommand::OnEnter()
{
	if (m_scenario==-1)
		return;

	if (m_text_text_panel)
		m_text_text_panel->GetText(m_text);

	sgCText* ttO = sgCText::Create(sgFontManager::GetFont(m_fnt),
										m_text_style,m_text);

	if (!ttO)
	{
		ASSERT(0);
		return;
	}

	ttO->InitTempMatrix()->SetMatrix(&m_matrix);
	ttO->ApplyTempMatrix();
	ttO->DestroyTempMatrix();

	sgGetScene()->StartUndoGroup();
	sgGetScene()->DetachObject(m_editable_text);
	sgGetScene()->AttachObject(ttO);
	sgGetScene()->EndUndoGroup();
	m_app->CopyAttributes(*ttO,*m_editable_text);
	m_app->GetViewPort()->InvalidateViewPort();
	m_app->StopCommander();
}
void  CEllipsoidEditCommand::OnEnter()
{
	if (!m_was_started)
		return;
	SWITCH_RESOURCE
		ASSERT(m_editable_ellipsoid);

	double sz = m_size_panel->GetNumber();

	switch(m_scenar) 
	{
	case 0:
		m_ell_geo.Radius1 = sz;
		break;
	case 1:
		m_ell_geo.Radius2 = sz;
		break;
	case 2:
		m_ell_geo.Radius3 = sz;
		break;
	default:
		ASSERT(0);
		break;
	}

	if (fabs(m_ell_geo.Radius1)<0.0001 ||
		fabs(m_ell_geo.Radius2)<0.0001 ||
		fabs(m_ell_geo.Radius3)<0.0001)
	{
		m_message.LoadString(IDS_ERROR_ZERO_SIZE);
		m_app->PutMessage(IApplicationInterface::MT_ERROR,
			m_message);
		return;
	}
	if (m_ell_geo.Radius1<0) m_ell_geo.Radius1=-m_ell_geo.Radius1;
	if (m_ell_geo.Radius2<0) m_ell_geo.Radius2=-m_ell_geo.Radius2;
	if (m_ell_geo.Radius3<0) m_ell_geo.Radius3=-m_ell_geo.Radius3;
	sgCEllipsoid* elpsd = sgCreateEllipsoid(m_ell_geo.Radius1,
		m_ell_geo.Radius2,m_ell_geo.Radius3,m_ell_geo.MeridiansCount,
		m_ell_geo.ParallelsCount);
	if (!elpsd)
		return;
	elpsd->InitTempMatrix()->Multiply(*m_matr);
	elpsd->ApplyTempMatrix();
	elpsd->DestroyTempMatrix();

	sgGetScene()->StartUndoGroup();
	sgGetScene()->DetachObject(m_editable_ellipsoid);
	sgGetScene()->AttachObject(elpsd);
	sgGetScene()->EndUndoGroup();
	m_app->CopyAttributes(*elpsd,*m_editable_ellipsoid);
	m_app->GetViewPort()->InvalidateViewPort();

	m_app->StopCommander();
}
Coons4Command::~Coons4Command()
{
	if (sgGetScene()->GetSelectedObjectsList()->GetCount()>0)
	{
		sgCObject*  curObj = sgGetScene()->GetSelectedObjectsList()->GetHead();
		while (curObj) 
		{
			curObj->Select(false);
			curObj = sgGetScene()->GetSelectedObjectsList()->GetNext(curObj);
		}
	}
	m_app->GetCommandPanel()->RemoveAllDialogs();
	m_app->GetViewPort()->InvalidateViewPort();
}
BOOL CNuGenDimensionDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	sgGetScene()->Clear();

  if (!CDocument::OnOpenDocument(lpszPathName))
    return FALSE;
  
  sgFileManager::Open(sgGetScene(),lpszPathName);

  CMainFrame*  mnFr = static_cast<CMainFrame*>(theApp.m_pMainWnd);
  mnFr->ResetNames();
  mnFr->UpdateSystemToolbar();

  return TRUE;
}
void OnBnClickedPrLines()
{
  sgGetScene()->Clear();

  for (double i=0.0;i<2.0*3.14159265;i+=0.1)
  {
      {
        sgCLine* ln = sgCreateLine(0, 0, 0.0, 5*cos(i), 5*sin(i), 0.0);
        sgGetScene()->AttachObject(ln);
        ln->SetAttribute(SG_OA_COLOR,((int)(10*i))%200);
        ln->SetAttribute(SG_OA_LINE_THICKNESS, ((int)(10*i))%5);
        ln->SetAttribute(SG_OA_LINE_TYPE, ((int)(10*i))%5);
      }
  }
}
void OnBnClickedPrPoints()
{
  sgGetScene()->Clear();

  for (int i=0;i<30;i++)
  {
    for (int j=0;j<30;j++)
      {
        double pZ = 0.05*(i-15)*(i-15)+0.03*(j-15)*(j-15);
        sgCPoint* pnt = sgCreatePoint(i-15, j-15, pZ);
        sgGetScene()->AttachObject(pnt);
        pnt->SetAttribute(SG_OA_COLOR,((int)pZ)%100);
        pnt->SetAttribute(SG_OA_LINE_THICKNESS, ((int)pZ)%3+1);
      }
  }
}
void CNuGenDimensionDoc::OnSTLImport()
{
	CString     Path;

	CFileDialog dlg(
		TRUE,
		NULL,               // Open File Dialog
		_T("*.stl"),              // Default extension
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, // No default filename
		_T("STL (*.stl)|*.stl||"));// Filter string

	if (dlg.DoModal() != IDOK)
		return;
	Path = dlg.GetPathName();

	GetDocTemplate()->OpenDocumentFile(NULL);

	sgFileManager::ImportSTL(sgGetScene(),Path.GetBuffer());

	POSITION pos = GetFirstViewPosition();
	while (pos != NULL)
	{
		CView* pView = GetNextView(pos);
		pView->OnInitialUpdate();
	}
	//AfxMessageBox("Sorry, its DEMO");
}
Exemple #12
0
void  AddFloorInScene(double size1, double size2, 
					  double x_shift, double y_shift, double z_shift)
{
	sgCObject*   objects_buffer[4];
	objects_buffer[0] = sgCreateLine(size1/2.0, size2/2.0, 0.0, 
		-size1/2.0, size2/2.0, 0.0);
	objects_buffer[1] = sgCreateLine(-size1/2.0, size2/2.0, 0.0, 
		-size1/2.0, -size2/2.0, 0.0);
	objects_buffer[2] = sgCreateLine(-size1/2.0, -size2/2.0, 0.0, 
		size1/2.0, -size2/2.0, 0.0);
	objects_buffer[3] = sgCreateLine(size1/2.0, -size2/2.0, 0.0, 
		size1/2.0, size2/2.0, 0.0);

	sgCContour*  cnt = sgCContour::CreateContour(objects_buffer,4);

	sgCObject*   floor = sgSurfaces::Face((const sgC2DObject&)(*cnt),NULL,0);
	sgDeleteObject(cnt);

	sgGetScene()->AttachObject(floor);
	floor->SetAttribute(SG_OA_COLOR,25);

	SG_VECTOR transV = {x_shift, y_shift, z_shift};
	floor->InitTempMatrix()->Translate(transV);
	floor->ApplyTempMatrix();
	floor->DestroyTempMatrix();

}
extern "C" AFX_EXT_API   void GetButtonState(unsigned int nID, bool& ch, bool& enbl)
{
	enbl = (sgGetScene()->GetObjectsList()->GetCount()>0);
	ch=false;
	if ((nID==startID) && (active_regime == REGIME_ROTATION))
	{
		ch=true;
	    return;
	}
	if ((nID==startID+1) && (active_regime == REGIME_EXTRUDE))
	{
		ch=true;
		return;
	}
	if ((nID==startID+2) && (active_regime == REGIME_SCREW))
	{
		ch=true;
		return;
	}
	if ((nID==startID+3) && (active_regime == REGIME_PIPE))
	{
		ch=true;
		return;
	}
}
void CNuGenDimensionView::OnInitialUpdate()
{
    COpenGLView::OnInitialUpdate();

    static_cast<CChildFrame*>(GetParentFrame())->SetView(this);

    m_Camera.ReInit();

    if (sgGetScene()->GetObjectsList()->GetCount()>0)
    {
        SG_POINT a1,a2;
        sgGetScene()->GetGabarits(a1,a2);
        m_Camera.FitBounds(a1.x,a1.y,a1.z,a2.x,a2.y,a2.z);
    }

    Invalidate();
}
BOOL CNuGenDimensionDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
#ifdef NUGEN_RETAIL
	sgFileManager::Save(sgGetScene(),lpszPathName, NULL, 0);
#else
    AfxMessageBox("This feature is not available in DEMO!");
#endif
  return TRUE;
}
void OnBnClickedPrCones()
{
  sgGetScene()->Clear();

  AddFloorInScene(200.0, 100.0, 50.0, 10.0, 5.0);

  for (int i=2;i<10;i++)
  {
    sgCCone* co1 = sgCreateCone(i,i/3,10*i,36);
    //SetMaterialToObject(co1,MATERIAL_METALL_BRONZE_1+i);
    SG_VECTOR transV1 = {10*i,10,10};
    co1->InitTempMatrix()->Translate(transV1);
    co1->ApplyTempMatrix();
    co1->DestroyTempMatrix();

    sgGetScene()->AttachObject(co1);
    co1->SetAttribute(SG_OA_COLOR,i);
  }
}
void OnBnClickedPrSplines()
{
  sgGetScene()->Clear();

  SG_SPLINE* spl1 = SG_SPLINE::Create();
  SG_POINT tmpPnt = {0.0, 0.0, 0.0};

  int fl=0;
  for (double i=0.0;i<2.0*3.14159265;i+=0.4)
  {
    tmpPnt.x = ((double)(fl%3))*cos(i);
    tmpPnt.y = ((double)(fl%3))*sin(i);
    tmpPnt.z = (fl%2)?1.0:-1.0;
    spl1->AddKnot(tmpPnt,fl);
    fl++;
  }

  sgCSpline* spl1_obj = sgCreateSpline(*spl1);
  sgGetScene()->AttachObject(spl1_obj);
  spl1_obj->SetAttribute(SG_OA_COLOR,10);
  spl1_obj->SetAttribute(SG_OA_LINE_THICKNESS, 2);

  SG_SPLINE::Delete(spl1);

  SG_SPLINE* spl2 = SG_SPLINE::Create();
  fl=0;
  for (double i=0.0;i<2.0*3.14159265;i+=0.4)
  {
    tmpPnt.x = ((double)(fl%3+2))*cos(i);
    tmpPnt.y = ((double)(fl%3+2))*sin(i);
    tmpPnt.z = 0.0;
    spl2->AddKnot(tmpPnt,fl);
    fl++;
  }
  spl2->Close();

  sgCSpline* spl2_obj = sgCreateSpline(*spl2);
  sgGetScene()->AttachObject(spl2_obj);
  spl2_obj->SetAttribute(SG_OA_COLOR,0);
  spl2_obj->SetAttribute(SG_OA_LINE_THICKNESS, 1);

  SG_SPLINE::Delete(spl2);
}
TranslateCommand::~TranslateCommand()
{
  if (sgGetScene()->GetSelectedObjectsList()->GetCount()>0)
  {
    sgCObject*  curObj = sgGetScene()->GetSelectedObjectsList()->GetHead();
    while (curObj)
    {
      curObj->Select(false);
      curObj = sgGetScene()->GetSelectedObjectsList()->GetNext(curObj);
    }
  }
  m_app->GetCommandPanel()->RemoveAllDialogs();
  if (m_panel)
  {
    m_panel->DestroyWindow();
    delete m_panel;
    m_panel = NULL;
  }
  m_app->GetViewPort()->InvalidateViewPort();
}
void OnBnClickedPrSphericBands()
{
  sgGetScene()->Clear();

  AddFloorInScene(40.0, 40.0, 15.0, 10.0, 0.0);

  for (int i=2;i<5;i++)
  {
    sgCSphericBand* sb1 = sgCreateSphericBand(i,-0.4, 0.5, 24);
    //SetMaterialToObject(sb1,MATERIAL_METALL_SILVER_1+i);
    SG_VECTOR transV1 = {5*i,10,10};
    sb1->InitTempMatrix()->Translate(transV1);
    sb1->ApplyTempMatrix();
    sb1->DestroyTempMatrix();

    sgGetScene()->AttachObject(sb1);
    sb1->SetAttribute(SG_OA_COLOR,i);
  }

}
Exemple #20
0
//
// DrawScene()
// Called each time the OpenGL scene has to be drawn.
//
void CDemoApp::DrawScene()
{
// TODO: Replace the following sample code with your code to draw the scene.

  sgCObject*  curObj = sgGetScene()->GetObjectsList()->GetHead();
  while (curObj)
  {
    if (true)
    {
      Painter::DrawObject(GL_RENDER,curObj,false);

      if ((curObj->GetAttribute(SG_OA_DRAW_STATE) & SG_DS_GABARITE))
      {
        SG_POINT a1,a2;
        curObj->GetGabarits(a1,a2);
        Painter::DrawGabariteBox(a1,a2);
      }
    }
    curObj = sgGetScene()->GetObjectsList()->GetNext(curObj);
  }
}
void OnBnClickedPrCircles()
{
  sgGetScene()->Clear();

  for (double i=0.0;i<2.0*3.14159265;i+=0.4)
  {
    SG_POINT   crCen = {5.0*cos(i),5.0*sin(i),0.0};
    SG_VECTOR  crNor;
    crNor.x = crCen.x - 0.0;
    crNor.y = crCen.y - 0.0;
    crNor.z = 0.0;
    sgSpaceMath::NormalVector(crNor);
    SG_CIRCLE  crGeo;
    crGeo.FromCenterRadiusNormal(crCen, 1, crNor);
    sgCCircle* cr = sgCreateCircle(crGeo);
    sgGetScene()->AttachObject(cr);
    cr->SetAttribute(SG_OA_COLOR,((int)(10*i))%200+50);
    cr->SetAttribute(SG_OA_LINE_THICKNESS, ((int)(10*i))%5);
    cr->SetAttribute(SG_OA_LINE_TYPE, ((int)(10*i))%5);
  }
}
void OnBnClickedPrSpheres()
{
  sgGetScene()->Clear();

  AddFloorInScene(20.0, 10.0, 0.0, 1.0, -2.0);

  for (int i=3;i<5;i++)
  {
      sgCSphere* sp1 = sgCreateSphere(i,24,24);

      //SetMaterialToObject(sp1,MATERIAL_GLASS_2+i);
      SG_VECTOR transV1 = {5*(i-3),2,0};
      sp1->InitTempMatrix()->Translate(transV1);
      sp1->ApplyTempMatrix();
      sp1->DestroyTempMatrix();

      sgGetScene()->AttachObject(sp1);
      sp1->SetAttribute(SG_OA_COLOR,i);
      if (i%2)
        sp1->SetAttribute(SG_OA_DRAW_STATE,SG_DS_FRAME);
  }
}
void OnBnClickedPrCyls()
{
  sgGetScene()->Clear();

  AddFloorInScene(80.0, 50.0, 20.0, 10.0, 5.0);

  for (int i=2;i<8;i++)
  {
    sgCCylinder* cy1 = sgCreateCylinder(i,2*i,24);
    //SetMaterialToObject(cy1,MATERIAL_METALL_GOLD_1+i);
    SG_VECTOR transV1 = {5*i,10,10};
    cy1->InitTempMatrix()->Translate(transV1);
    cy1->ApplyTempMatrix();
    cy1->DestroyTempMatrix();

    sgGetScene()->AttachObject(cy1);
    cy1->SetAttribute(SG_OA_COLOR,i);

    if (i%2)
      cy1->SetAttribute(SG_OA_DRAW_STATE,SG_DS_FRAME);
  }
}
void OnBnClickedPrTors()
{
  sgGetScene()->Clear();

  AddFloorInScene(100.0, 50.0, 50.0, 10.0, 2.0);

  for (int i=2;i<10;i++)
  {
    sgCTorus* tor1 = sgCreateTorus(i,i/6+2,24,24);
    //SetMaterialToObject(tor1,MATERIAL_METALL_CHROME_1+i);
    SG_POINT rotCen = {0.0,0.0,0.0};
    SG_VECTOR rotDir = {rand(),rand(),rand()};
    tor1->InitTempMatrix()->Rotate(rotCen,rotDir, rand()*360);
    SG_VECTOR transV1 = {10*i,10,10};
    tor1->GetTempMatrix()->Translate(transV1);
    tor1->ApplyTempMatrix();
    tor1->DestroyTempMatrix();

    sgGetScene()->AttachObject(tor1);
    tor1->SetAttribute(SG_OA_COLOR,i);
  }

}
void OnBnClickedPrEllipsoids()
{
  sgGetScene()->Clear();

  AddFloorInScene(100.0, 50.0, 50.0, 10.0, 2.0);

  for (int i=3;i<10;i++)
  {
    sgCEllipsoid* ell1 = sgCreateEllipsoid(i,i/6+2,2*i, 24,24);
    //SetMaterialToObject(ell1,MATERIAL_GLASS_1+i);
    SG_POINT rotCen = {0.0,0.0,0.0};
    SG_VECTOR rotDir = {rand(),rand(),rand()};
    ell1->InitTempMatrix()->Rotate(rotCen,rotDir, rand()*360);
    SG_VECTOR transV1 = {10*i,10,10};
    ell1->GetTempMatrix()->Translate(transV1);
    ell1->ApplyTempMatrix();
    ell1->DestroyTempMatrix();

    sgGetScene()->AttachObject(ell1);
    ell1->SetAttribute(SG_OA_COLOR,i);
    
  }
}
void OnBnClickedPrArcs()
{
  sgGetScene()->Clear();

  for (double i=0.0;i<2.0*3.14159265;i+=0.8)
  {
    SG_POINT   arP1 = {5.0*cos(i),5.0*sin(i),0.0};
    SG_POINT   arP2 = {5.0*cos(i+0.4),5.0*sin(i+0.4),0.0};
    SG_POINT   arP3 = {7.0*cos(i+0.2),7.0*sin(i+0.2),3.0};
    SG_ARC     arGeo;
    if (arGeo.FromThreePoints(arP1, arP2, arP3,false))
    {
      sgCArc* ar = sgCreateArc(arGeo);
      if (ar)
      {
        sgGetScene()->AttachObject(ar);
        ar->SetAttribute(SG_OA_COLOR,((int)(10*i))%200+50);
        ar->SetAttribute(SG_OA_LINE_THICKNESS, ((int)(10*i))%5);
        ar->SetAttribute(SG_OA_LINE_TYPE, ((int)(10*i))%5);
      }
    }
  }
}
void  CEllipsoidEditCommand::LeftClick(unsigned int nFlags,int pX,int pY)
{
	if (!m_was_started)
		return;
	SWITCH_RESOURCE
		ASSERT(m_editable_ellipsoid);

	if (fabs(m_ell_geo.Radius1)<0.0001 ||
		fabs(m_ell_geo.Radius2)<0.0001 ||
		fabs(m_ell_geo.Radius3)<0.0001)
	{
		m_message.LoadString(IDS_ERROR_ZERO_SIZE);
		m_app->PutMessage(IApplicationInterface::MT_ERROR,
			m_message);
		return;
	}
	if (m_ell_geo.Radius1<0) m_ell_geo.Radius1=-m_ell_geo.Radius1;
	if (m_ell_geo.Radius2<0) m_ell_geo.Radius2=-m_ell_geo.Radius2;
	if (m_ell_geo.Radius3<0) m_ell_geo.Radius3=-m_ell_geo.Radius3;
	sgCEllipsoid* elpsd = sgCreateEllipsoid(m_ell_geo.Radius1,
		m_ell_geo.Radius2,m_ell_geo.Radius3,m_ell_geo.MeridiansCount,
		m_ell_geo.ParallelsCount);
	if (!elpsd)
		return;
	elpsd->InitTempMatrix()->Multiply(*m_matr);
	elpsd->ApplyTempMatrix();
	elpsd->DestroyTempMatrix();

	sgGetScene()->StartUndoGroup();
	sgGetScene()->DetachObject(m_editable_ellipsoid);
	sgGetScene()->AttachObject(elpsd);
	sgGetScene()->EndUndoGroup();
	m_app->CopyAttributes(*elpsd,*m_editable_ellipsoid);
	m_app->GetViewPort()->InvalidateViewPort();

	m_app->StopCommander();
}
void TranslateCommand::Draw()
{
  if (m_step==0)
    return ;

  glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT|GL_CURRENT_BIT|GL_LIGHTING_BIT);

  glDisable(GL_TEXTURE_2D);
  glDisable(GL_DEPTH_TEST);
  glLineWidth(3);
  glEnable(GL_LINE_SMOOTH);

  drawTransArrows();

  if (m_panel->IsDouble())
  {
      glEnable(GL_DEPTH_TEST);
      sgCObject*  curObj = sgGetScene()->GetSelectedObjectsList()->GetHead();
      while (curObj)
      {
        if (curObj->GetTempMatrix()==NULL)
          curObj->InitTempMatrix();
        int cc =m_panel->GetCopiesCount();
        for(int j=0;j<cc;j++)
        {
          curObj->GetTempMatrix()->Translate(m_trans_vector);
          Drawer::DrawObject(GL_RENDER,curObj,false);
        }
        curObj->DestroyTempMatrix();
        curObj = sgGetScene()->GetSelectedObjectsList()->GetNext(curObj);
      }
  }


  glPopAttrib();
}
BOOL CNuGenDimensionDoc::OnNewDocument()
{
  if (!CDocument::OnNewDocument())
    return FALSE;

  sgGetScene()->Clear();

  memset(&m_scene_setups,0,sizeof(SCENE_SETUPS));
  m_scene_setups.CurrentColor = 8;

  CMainFrame*  mnFr = static_cast<CMainFrame*>(theApp.m_pMainWnd);
  mnFr->ResetNames();
  mnFr->UpdateSystemToolbar();

  return TRUE;
}
void CNuGenDimensionDoc::OnSTLExport()
{
#ifdef NUGEN_RETAIL
	CString     Path;

	CFileDialog dlg(
		FALSE,
		NULL,               // Open File Dialog
		_T(""),             // Default extension
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, // No default filename
		_T("STL (*.stl)|*.stl||"));// Filter string

	if (dlg.DoModal() != IDOK)
		return;
	Path = dlg.GetPathName();
	if (Path.Right(4)!=".stl")
		Path+=".stl";

	sgFileManager::ExportSTL(sgGetScene(),Path.GetBuffer());
#else
    AfxMessageBox("This feature is not available in DEMO!");
#endif
}