void COptimizeWallWnd::OutputToLines(vector<sOpWall>& sOpWalls)
{
	//外墙
	CMFCPropertyGridProperty* outWallPos = getCoodOutWallGroup();
	sOpWall w;
	for (int i = 0; i < outWallPos->GetSubItemsCount(); i++)
	{
		w.line.s.x = outWallPos->GetSubItem(i)->GetSubItem(0)->GetSubItem(0)->GetValue().dblVal;
		w.line.s.y = outWallPos->GetSubItem(i)->GetSubItem(0)->GetSubItem(1)->GetValue().dblVal;
		w.line.e.x = outWallPos->GetSubItem(i)->GetSubItem(1)->GetSubItem(0)->GetValue().dblVal;
		w.line.e.y = outWallPos->GetSubItem(i)->GetSubItem(1)->GetSubItem(1)->GetValue().dblVal;
		w.line.type = sLine::OUT_WALL;
		CString mat = outWallPos->GetSubItem(i)->GetSubItem(2)->GetValue().bstrVal;
		_tcscpy_s(w.mat, mat);

		sOpWalls.push_back(w);
	}

	//内墙
	CMFCPropertyGridProperty* inWallPos = getCoodInWallGroup();
	for (int i = 0; i < inWallPos->GetSubItemsCount(); i++)
	{
		w.line.s.x = inWallPos->GetSubItem(i)->GetSubItem(0)->GetSubItem(0)->GetValue().dblVal;
		w.line.s.y = inWallPos->GetSubItem(i)->GetSubItem(0)->GetSubItem(1)->GetValue().dblVal;
		w.line.e.x = inWallPos->GetSubItem(i)->GetSubItem(1)->GetSubItem(0)->GetValue().dblVal;
		w.line.e.y = inWallPos->GetSubItem(i)->GetSubItem(1)->GetSubItem(1)->GetValue().dblVal;
		w.line.type = sLine::IN_WALL;
		CString mat = inWallPos->GetSubItem(i)->GetSubItem(2)->GetValue().bstrVal;
		_tcscpy_s(w.mat, mat);

		sOpWalls.push_back(w);
	}
}
Example #2
0
void CPropertiesWnd::ChangeSelection(CMFCPropertyGridProperty* pNewSel, CMFCPropertyGridProperty* /*pOldSel*/)
{
	if (pNewSel == NULL)
	{
		((CMainFrame*)AfxGetMainWnd())->GetClassView()->SetPreviewProp(NULL);
		return;
	}

	CString strPreview;
	if (IsComboType())
	{
		if (pNewSel->IsGroup())
		{
			CString strName(pNewSel->GetName());
			if (strName.CompareNoCase(_T("ITEM")) == 0)
			{
				CMFCPropertyGridProperty* pPreviewProp = pNewSel->GetSubItem(pNewSel->GetSubItemsCount() - 1);
				((CMainFrame*)AfxGetMainWnd())->GetClassView()->SetPreviewProp(pPreviewProp);
				return;
			}
		}
		else
		{
			CMFCPropertyGridProperty* pGroupProp = pNewSel->GetParent();
			CString strName(pGroupProp->GetName());
			if (strName.CompareNoCase(_T("ITEM")) == 0)
			{
				CMFCPropertyGridProperty* pPreviewProp = pGroupProp->GetSubItem(pGroupProp->GetSubItemsCount() - 1);
				((CMainFrame*)AfxGetMainWnd())->GetClassView()->SetPreviewProp(pPreviewProp);
				return;
			}
		}
		((CMainFrame*)AfxGetMainWnd())->GetClassView()->SetPreviewProp(NULL);
	}
	else
	{
		// the last is preview
		CMFCPropertyGridProperty* pGroupProp = pNewSel;
		if (!pNewSel->IsGroup())
		{
			pGroupProp = pNewSel->GetParent();
		}

		if (pGroupProp->GetSubItemsCount() > 2)
		{
			CMFCPropertyGridProperty* pPreviewProp = pGroupProp->GetSubItem(pGroupProp->GetSubItemsCount() - 1);
			((CMainFrame*)AfxGetMainWnd())->GetClassView()->SetPreviewProp(pPreviewProp);
		}
	}
}
Example #3
0
void CPropertiesWnd::OnPropDownitem()
{
	if (!IsComboType())
	{
		return;
	}

	CMFCPropertyGridProperty *pProp = m_wndPropList.GetCurSel();
	if (pProp && pProp->IsGroup())
	{
		CString strName(pProp->GetName());
		if (strName.CompareNoCase(_T("ITEM")) == 0)
		{
			CMFCPropertyGridProperty *pParentProp = pProp->GetParent();
			if (pProp == pParentProp->GetSubItem(pParentProp->GetSubItemsCount() - 1))
			{
				return;
			}

			int nEnd = 0;
			CList<CMFCPropertyGridProperty*, CMFCPropertyGridProperty*> lstSubItems;
			for (int i = pParentProp->GetSubItemsCount() - 1; i >= nEnd; i--)
			{
				CMFCPropertyGridProperty *pChildProp = pParentProp->GetSubItem(i);
				if (pChildProp)
				{
					if (pChildProp == pProp)
					{
						nEnd = i;
						lstSubItems.InsertAfter(lstSubItems.GetHeadPosition(), pChildProp);
					}
					else
					{
						lstSubItems.AddHead(pChildProp);
					}
					pParentProp->RemoveSubItem(pChildProp, FALSE);
				}
			}

			for (POSITION pos = lstSubItems.GetHeadPosition(); pos != NULL;)
			{
				CMFCPropertyGridProperty* pProp = lstSubItems.GetNext(pos);
				ASSERT_VALID(pProp);

				pParentProp->AddSubItem(pProp);
			}
			m_wndPropList.AdjustLayout();
		}
	}
}
Example #4
0
void CFileView::RefreshPropName(CMFCPropertyGridProperty* pProp)
{
	CMFCPropertyGridProperty* pGroupProp = GetSelectItemProp();
	if (pGroupProp && pGroupProp->GetSubItemsCount() > 0 && pGroupProp->GetSubItem(0) == pProp)
	{
		HTREEITEM hItem = m_wndFileView.GetSelectedItem();
		m_wndFileView.SetItemText(hItem, (CString)pProp->GetValue());
	}
}
void COptimizeWallWnd::InsertPos(bool isOutWall, double x, double y, double x1, double y1, CString mat)
{
	CMainFrame* pMain=(CMainFrame*)AfxGetApp()->m_pMainWnd;  
	CBuildLightAnalysisDoc* pDoc = (CBuildLightAnalysisDoc*)pMain->GetActiveDocument();
	if (!pMain || !pDoc)
		return;

	CMFCPropertyGridProperty* pGroup = NULL;
	if (isOutWall)
	{
		pGroup = getCoodOutWallGroup();
	}
	else
	{
		pGroup = getCoodInWallGroup();
	}
		
	int count = pGroup->GetSubItemsCount();
	CString strCount;
	strCount.Format(_T("%d"),count);

	PropertyGridProperty* pPos = new PropertyGridProperty(strCount, 0, TRUE);

	PropertyGridProperty* pStart = new PropertyGridProperty(_T("起点"), 0, TRUE);
	PropertyGridProperty* pProp = new PropertyGridProperty(_T("X(mm)"), (_variant_t) x, _T("坐标X"));
	pStart->AddSubItem(pProp);
	pProp = new PropertyGridProperty( _T("Y(mm)"), (_variant_t) y, _T("坐标Y"));
	pStart->AddSubItem(pProp);

	PropertyGridProperty* pEnd = new PropertyGridProperty(_T("终点"), 0, TRUE);
	pProp = new PropertyGridProperty(_T("X(mm)"), (_variant_t) x1, _T("坐标X"));
	pEnd->AddSubItem(pProp);
	pProp = new PropertyGridProperty( _T("Y(mm)"), (_variant_t) y1, _T("坐标Y"));
	pEnd->AddSubItem(pProp);

	PropertyGridProperty* pMat = new PropertyGridProperty(_T("材质"), mat, _T("墙材质"));
	vector<Material>& mats = pDoc->getMaterials();
	for (int i = 0; i < mats.size(); i++)
	{
		pMat->AddOption(StringToCString(mats[i].name));
	}
	pMat->AllowEdit(FALSE);
	pPos->AddSubItem(pStart);
	pPos->AddSubItem(pEnd);
	pPos->AddSubItem(pMat);


	pGroup->AddSubItem(pPos);

	m_wndPropList.UpdateProperty((PropertyGridProperty*)(pGroup));
	m_wndPropList.AdjustLayout();
}
Example #6
0
void CPropertiesWnd::PropertyChanged(CMFCPropertyGridProperty* pProp)
{
	CString strName(pProp->GetName());
	if (strName.CompareNoCase(_T("TYPE")) == 0)
	{
		CMFCPropertyGridProperty* pPropGroup = pProp->GetParent();
		for (int i = pPropGroup->GetSubItemsCount() - 1; i >= 0; i--)
		{
			CMFCPropertyGridProperty* pChildProp = pPropGroup->GetSubItem(i);
			if (pChildProp == pProp)
			{
				break;
			}
			pPropGroup->RemoveSubItem(pChildProp);
		}

		CString strType(pProp->GetValue());
		if (strType.CompareNoCase(_T("Combo")) == 0)
		{
			CMFCPropertyGridProperty* pNewProp = new CMFCPropertyGridProperty(_T("VALUE"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("ITEMS"), PROP_DATA_ITEMS, TRUE);
			pPropGroup->AddSubItem(pNewProp);
		}
		else if (strType.CompareNoCase(_T("Number")) == 0)
		{ 
			CMFCPropertyGridProperty* pNewProp = new CMFCPropertyGridProperty(_T("VALUE"), (_variant_t)0, _T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("RANGE MIN"), (_variant_t)0, _T(""));
			pNewProp->EnableSpinControl(TRUE, -9999, 9999);
			pPropGroup->AddSubItem(pNewProp);
			pNewProp = new CMFCPropertyGridProperty(_T("RANGE MAX"), (_variant_t)100, _T(""));
			pNewProp->EnableSpinControl(TRUE, -9999, 9999);
			pPropGroup->AddSubItem(pNewProp);

			BOOL bBuddy = FALSE;
			pNewProp = new CMFCPropertyGridProperty(_T("BUDDY"), (_variant_t)(bBuddy == TRUE), _T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("SHORT"), (_variant_t)_T(""), _T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("PREVIEW"), (_variant_t)_T(""), _T(""));
			pPropGroup->AddSubItem(pNewProp);
		}
		else if (strType.CompareNoCase(_T("Text")) == 0)
		{
			CMFCPropertyGridProperty* pNewProp = new CMFCPropertyGridProperty(_T("VALUE"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("SHORT"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("PREVIEW"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);
		}

		m_wndPropList.AdjustLayout();
	}
	else if (strName.CompareNoCase(_T("PREVIEW")) == 0)
	{
		((CMainFrame*)AfxGetMainWnd())->GetClassView()->RefreshPreview();
	}
	else if (strName.CompareNoCase(_T("NAME")) == 0)
	{
		((CMainFrame*)AfxGetMainWnd())->GetFileView()->RefreshPropName(pProp);
	}
	((CMainFrame*)AfxGetMainWnd())->GetFileView()->SetFileModifiedFlag(TRUE);
}