home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Houseplan Collection
/
HRCD2005.ISO
/
data1.cab
/
Zusatz
/
3DS
/
DATA2.Z
/
DachHolzkonstructionDlg.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-04-28
|
6KB
|
206 lines
// DachHolzkonstructionDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DachHolzkonstruction.h"
#include "DachHolzkonstructionDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDachHolzkonstructionDlg dialog
CDachHolzkonstructionDlg::CDachHolzkonstructionDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDachHolzkonstructionDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDachHolzkonstructionDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_prog = NULL;
}
void CDachHolzkonstructionDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDachHolzkonstructionDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDachHolzkonstructionDlg, CDialog)
//{{AFX_MSG_MAP(CDachHolzkonstructionDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CREATE_ROOF, OnCreateRoof)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDachHolzkonstructionDlg message handlers
BOOL CDachHolzkonstructionDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
if (FAILED(CoCreateInstance(CLSID_ArCon, NULL, CLSCTX_LOCAL_SERVER, IID_IArCon, (void**)&m_prog))) {
AfxMessageBox(IDS_NO_ARCON);
PostQuitMessage(0);
return TRUE;
}
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CDachHolzkonstructionDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CDachHolzkonstructionDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDachHolzkonstructionDlg::OnDestroy()
{
if (m_prog) {
m_prog->Release();
m_prog = NULL;
}
CDialog::OnDestroy();
}
void CDachHolzkonstructionDlg::OnCreateRoof()
{
VARIANT_BOOL result;
// Makro mit ArCon verbinden
m_prog->StartMe((long)m_hWnd, NULL, &result);
// Testen, ob ein Projekt geladen ist
long val;
m_prog->get_Mode(&val);
if (val == AC_NoMode) {
// Kein Projekt geladen, wir brauchen ein neues
IProject * prj;
m_prog->NewProject(&prj);
m_prog->CreateProject(prj);
prj->Release();
}
// In den Konstruktionsmodus schalten
m_prog->put_Mode(AC_ModeConstruct);
// Neue Dachkonstruktion beginnen
IRoofConstruction * constr;
m_prog->NewRoofConstruction(&constr);
// erste DachflΣche definieren
constr->BeginNewArea(ACDACH_FlaecheEindeckung, &result);
constr->AddPoint(0.0, 0.0, 0.0, &result);
constr->AddPoint(10.0, 0.0, 0.0, &result);
constr->AddPoint(10.0, 4.0, 4.0, &result);
constr->AddPoint(0.0, 4.0, 4.0, &result);
// zweite DachflΣchen definieren
constr->BeginNewArea(ACDACH_FlaecheEindeckung, &result);
constr->AddPoint(10.0, 8.0, 0.0, &result);
constr->AddPoint(0.0, 8.0, 0.0, &result);
constr->AddPoint(0.0, 4.0, 4.0, &result);
constr->AddPoint(10.0, 4.0, 4.0, &result);
// Balken erzeugen
int i;
double dx;
const double PI = 3.1415926;
const double TexDirX = 0.0;
const double TexDirY = 45.0 * PI / 180.0;
const double TexDirZ = 90.0 * PI / 180.0;
const double dBreite = 0.08;
const double dDicke = 0.16;
const double dAbstand = 0.8;
dx = 0.0;
for (i = 0; i < 10; i++) {
// Neuer Sparren (der Name ist optional)
CString name;
name.LoadString(IDS_NAME_SPARREN);
constr->NewRafter(ACRWOOD_Sparren, name.AllocSysString(), dBreite, dDicke, &result);
// Ausrichtung festlegen
constr->RafterSetGeo(ACRAFTER_TextureDir, TexDirX, TexDirY, TexDirZ, &result);
// Erster Eckpunkt
constr->RafterSetGeo(ACRAFTER_Left1, dx + 0.2, 0.0, 0.0, &result);
constr->RafterSetGeo(ACRAFTER_Right1, dx + 0.28, 0.0, 0.0, &result);
// Zweiter Eckpunkt
constr->RafterSetGeo(ACRAFTER_Left1, dx + 0.2, 4.0, 4.0, &result);
constr->RafterSetGeo(ACRAFTER_Right1, dx + 0.28, 4.0, 4.0, &result);
// Dritter Eckpunkt
constr->RafterSetGeo(ACRAFTER_Left1, dx + 0.2, 4.0, 4.0 - 0.16 / 0.707, &result);
constr->RafterSetGeo(ACRAFTER_Right1, dx + 0.28, 4.0, 4.0 - 0.16 / 0.707, &result);
// Vierter Eckpunkt
constr->RafterSetGeo(ACRAFTER_Left1, dx + 0.2, 0.0, 0.0 - 0.16 / 0.707, &result);
constr->RafterSetGeo(ACRAFTER_Right1, dx + 0.28, 0.0, 0.0 - 0.16 / 0.707, &result);
dx = dx + dAbstand;
}
// Analyse der Geometrie durchfⁿhren (ohne automatische Unterfⁿllung)
constr->Analyze(FALSE, &result);
// Alles klar?
BSTR err = NULL;
constr->get_Fehler(&err);
if (SysStringLen(err) > 0) {
CString msg(err);
AfxMessageBox(msg);
} else {
// Die Konstruktion ist vollstΣndig - Dach erzeugen
IRoof * roof = NULL;
IStory * story = NULL;
m_prog->get_CurrentStory(&story);
constr->CreateRoof(story, &roof);
if (story) story->Release();
if (roof) roof->Release();
}
SysFreeString(err);
constr->Release();
// Fertig, Makro Verbindung zu ArCon terminieren
m_prog->EndMe();
}