/
DisplayObjectFactory.cpp
executable file
·104 lines (84 loc) · 3.67 KB
/
DisplayObjectFactory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
///////////////////////////////////////////////////////////////////////
// XBeamRate - Cross Beam Load Rating
// Copyright © 1999-2024 Washington State Department of Transportation
// Bridge and Structures Office
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the Alternate Route Open Source License as
// published by the Washington State Department of Transportation,
// Bridge and Structures Office.
//
// This program is distributed in the hope that it will be useful, but
// distribution is AS IS, WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the Alternate Route Open Source License for more details.
//
// You should have received a copy of the Alternate Route Open Source
// License along with this program; if not, write to the Washington
// State Department of Transportation, Bridge and Structures Office,
// P.O. Box 47340, Olympia, WA 98503, USA or e-mail
// Bridge_Support@wsdot.wa.gov
///////////////////////////////////////////////////////////////////////
// DisplayObjectFactory.cpp : implementation file
//
#include "stdafx.h"
#include "DisplayObjectFactory.h"
#include "mfcdual.h"
#include "SectionCut.h"
#include <WBFLDManip.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDisplayObjectFactory
CDisplayObjectFactory::CDisplayObjectFactory()
{
::CoCreateInstance(CLSID_DisplayObjectFactory,nullptr,CLSCTX_ALL,IID_iDisplayObjectFactory,(void**)&m_Factory);
}
CDisplayObjectFactory::~CDisplayObjectFactory()
{
}
BEGIN_INTERFACE_MAP(CDisplayObjectFactory,CCmdTarget)
INTERFACE_PART(CDisplayObjectFactory,IID_iDisplayObjectFactory,Factory)
END_INTERFACE_MAP()
DELEGATE_CUSTOM_INTERFACE(CDisplayObjectFactory,Factory);
/////////////////////////////////////////////////////////////////////////////
// CDisplayObjectFactory message handlers
STDMETHODIMP_(void) CDisplayObjectFactory::XFactory::Create(CLIPFORMAT cfFormat,COleDataObject* pDataObject,iDisplayObject** dispObj)
{
METHOD_PROLOGUE(CDisplayObjectFactory,Factory);
if ( cfFormat == CSectionCutDisplayImpl::ms_Format )
{
CComPtr<iPointDisplayObject> doSectionCut;
::CoCreateInstance(CLSID_PointDisplayObject,nullptr,CLSCTX_ALL,IID_iPointDisplayObject,(void**)&doSectionCut);
doSectionCut->SetSelectionType(stAll);
CSectionCutDisplayImpl* pDisplayImpl = new CSectionCutDisplayImpl();
CComPtr<iDrawPointStrategy> strategy;
strategy.Attach((iDrawPointStrategy*)pDisplayImpl->GetInterface(&IID_iDrawPointStrategy));
doSectionCut->SetDrawingStrategy(strategy);
CComPtr<iDisplayObjectEvents> events;
events.Attach((iDisplayObjectEvents*)pDisplayImpl->GetInterface(&IID_iDisplayObjectEvents));
doSectionCut->RegisterEventSink(events.Detach());
CComPtr<iDragData> dragData;
dragData.Attach((iDragData*)pDisplayImpl->GetInterface(&IID_iDragData));
CComQIPtr<iDraggable,&IID_iDraggable> draggable(doSectionCut);
draggable->SetDragData(dragData.Detach());
if ( pDataObject )
{
// Initialize from data object
CComPtr<iDragDataSource> source;
::CoCreateInstance(CLSID_DragDataSource,nullptr,CLSCTX_ALL,IID_iDragDataSource,(void**)&source);
source->SetDataObject(pDataObject);
// rebuild the display object from the data source
draggable->OnDrop(source);
}
(*dispObj) = doSectionCut;
(*dispObj)->AddRef();
}
else
{
pThis->m_Factory->Create(cfFormat,pDataObject,dispObj);
}
}