bool CWKSP_Shapes::_Edit_Shape_Stop(bool bSave)
{
	if( m_Edit_pShape != NULL )
	{
		if( bSave )
		{
			CSG_Shape	*pShape	= Get_Shapes()->Get_Selection(m_Edit_Index);

			if( pShape == NULL )
			{
				Get_Shapes()->Select(pShape = Get_Shapes()->Add_Shape());

				m_Edit_Index	= 0;
			}

			if( pShape != NULL )
			{
				pShape->Assign(m_Edit_pShape, false);
			}
		}

		m_Edit_Shapes.Del_Shapes();
		m_Edit_pShape	= NULL;
		m_Edit_Mode		= EDIT_SHAPE_MODE_Normal;

		Edit_Set_Index(m_Edit_Index);

		Update_Views();

		return( true );
	}

	return( false );
}
Exemplo n.º 2
0
//---------------------------------------------------------
bool CSG_Shapes::Assign(CSG_Data_Object *pObject)
{
	int			iShape;
	CSG_Shape	*pShape;
	CSG_Shapes	*pShapes;

	//-----------------------------------------------------
	if(	pObject && pObject->is_Valid() && (pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes || pObject->Get_ObjectType() == DATAOBJECT_TYPE_PointCloud) )
	{
		pShapes	= (CSG_Shapes *)pObject;

		Create(pShapes->Get_Type(), pShapes->Get_Name(), pShapes, pShapes->Get_Vertex_Type());

		for(iShape=0; iShape<pShapes->Get_Count() && SG_UI_Process_Set_Progress(iShape, pShapes->Get_Count()); iShape++)
		{
			pShape	= Add_Shape();
			pShape->Assign(pShapes->Get_Shape(iShape));
		}

		SG_UI_Process_Set_Ready();

		Update();

		Get_History()	= pObject->Get_History();

		return( true );
	}

	return( false );
}
Exemplo n.º 3
0
//---------------------------------------------------------
CSG_Shape * CSG_Shapes::Add_Shape(CSG_Table_Record *pCopy, TSG_ADD_Shape_Copy_Mode mCopy)
{
	CSG_Shape	*pShape	= (CSG_Shape *)Add_Record();

	if( pShape && pCopy )
	{
		if( (mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_ATTR) )
		{
			((CSG_Table_Record *)pShape)->Assign(pCopy);
		}

		if( (mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_GEOM) && pCopy->Get_Table()->Get_ObjectType() == DATAOBJECT_TYPE_Shapes )
		{
			pShape->Assign((CSG_Shape *)pCopy, false);
		}
	}

	return( pShape );
}
//---------------------------------------------------------
bool CWKSP_Shapes::_Edit_Split(void)
{
	if( Get_Shapes()->Get_Type() == SHAPE_TYPE_Polygon
	||  Get_Shapes()->Get_Type() == SHAPE_TYPE_Line )
	{
		switch( m_Edit_Mode )
		{
		default:
			break;

		//-------------------------------------------------
		case EDIT_SHAPE_MODE_Normal:
			m_Edit_Mode	= EDIT_SHAPE_MODE_Split;

			if( m_Edit_Shapes.Get_Count() == 0 )
			{
				m_Edit_Shapes.Add_Shape(Get_Shapes()->Get_Selection());
			}

			if( m_Edit_Shapes.Get_Count() > 1 )
			{
				m_Edit_Shapes.Get_Shape(1)->Del_Parts();
			}
			else
			{
				m_Edit_Shapes.Add_Shape();
			}

			return( true );

		//-------------------------------------------------
		case EDIT_SHAPE_MODE_Split:
			m_Edit_Mode	= EDIT_SHAPE_MODE_Normal;

			CSG_Module	*pModule	= Get_Shapes()->Get_Type() == SHAPE_TYPE_Polygon
			?	SG_Get_Module_Library_Manager().Get_Module(SG_T("shapes_polygons"), 8)	// Polygon-Line Intersection
			:	SG_Get_Module_Library_Manager().Get_Module(SG_T("shapes_lines"   ), 6); // Split Lines with Lines

			if(	pModule )
			{
				CSG_Shapes	Line(SHAPE_TYPE_Line), Split(Get_Shapes()->Get_Type());

				Line.Add_Shape();

				for(int i=0; i<m_Edit_Shapes.Get_Shape(1)->Get_Point_Count(); i++)
				{
					Line.Get_Shape(0)->Add_Point(m_Edit_Shapes.Get_Shape(1)->Get_Point(i));
				}

				m_Edit_Shapes.Del_Shape(1);

				//-----------------------------------------
				bool	bResult;

				CSG_Parameters	P; P.Assign(pModule->Get_Parameters());

				pModule->Set_Manager(NULL);

				if( Get_Shapes()->Get_Type() == SHAPE_TYPE_Polygon )
				{
					bResult	= pModule->Get_Parameters()->Set_Parameter("POLYGONS" , &m_Edit_Shapes)
						&&    pModule->Get_Parameters()->Set_Parameter("LINES"    , &Line)
						&&    pModule->Get_Parameters()->Set_Parameter("INTERSECT", &Split)
						&&    pModule->Execute();
				}
				else //	if( Get_Shapes()->Get_Type() == SHAPE_TYPE_Line )
				{
					bResult	= pModule->Get_Parameters()->Set_Parameter("LINES"    , &m_Edit_Shapes)
						&&    pModule->Get_Parameters()->Set_Parameter("SPLIT"    , &Line)
						&&    pModule->Get_Parameters()->Set_Parameter("INTERSECT", &Split)
						&&    pModule->Execute();
				}

				//-----------------------------------------
				if( bResult )
				{
					if( m_Edit_pShape )
					{
						m_Edit_pShape->Assign(Split.Get_Shape(0), false);

						for(int iSplit=1; iSplit<Split.Get_Count(); iSplit++)
						{
							CSG_Shape	*pSplit	= Split.Get_Shape(iSplit);

							for(int iPart=0; iPart<pSplit->Get_Part_Count(); iPart++)
							{
								for(int iPoint=0, jPart=m_Edit_pShape->Get_Part_Count(); iPoint<pSplit->Get_Point_Count(iPart); iPoint++)
								{
									m_Edit_pShape->Add_Point(pSplit->Get_Point(iPoint, iPart), jPart);
								}
							}
						}
					}
					else if( Get_Shapes()->Get_Selection_Count() == 1 ) // if( !m_Edit_pShape )
					{
						CSG_Shape	*pSelection	= Get_Shapes()->Get_Selection();
						
						pSelection->Assign(Split.Get_Shape(0), false);

						for(int iSplit=1; iSplit<Split.Get_Count(); iSplit++)
						{
							CSG_Shape	*pSplit	= Get_Shapes()->Add_Shape(Split.Get_Shape(iSplit));

							((CSG_Table_Record *)pSplit)->Assign(pSelection);

							Get_Shapes()->Select(pSplit, true);
						}

						m_Edit_Shapes.Del_Shapes();
					}
				}

				pModule->Get_Parameters()->Assign_Values(&P);
				pModule->Set_Manager(P.Get_Manager());
			}

			Update_Views(false);

			return( true );
		}
	}

	return( false );
}