Skip to content

Commit

Permalink
add G3DWarehouseBrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
opencollada-sebastian committed Nov 6, 2009
1 parent acb8fe4 commit eab47d4
Show file tree
Hide file tree
Showing 19 changed files with 1,758 additions and 0 deletions.
26 changes: 26 additions & 0 deletions G3DWarehouseBrowser/G3DWarehouseBrowser.sln
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "G3DWarehouseBrowser", "scripts\G3DWarehouseBrowser.vcproj", "{81F6BA2E-BB3A-4D67-AC12-A112946EB832}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Debug|Win32.ActiveCfg = Debug|Win32
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Debug|Win32.Build.0 = Debug|Win32
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Debug|x64.ActiveCfg = Debug|x64
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Debug|x64.Build.0 = Debug|x64
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Release|Win32.ActiveCfg = Release|Win32
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Release|Win32.Build.0 = Release|Win32
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Release|x64.ActiveCfg = Release|x64
{81F6BA2E-BB3A-4D67-AC12-A112946EB832}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
65 changes: 65 additions & 0 deletions G3DWarehouseBrowser/include/G3DBrowser.h
@@ -0,0 +1,65 @@
/*
Copyright (c) 2009 NetAllied Systems GmbH
This file is part of G3DWarehouseBrowser.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/

#ifndef __G3D_BROWSER_H__
#define __G3D_BROWSER_H__

#include "G3DPrerequisites.h"
#include <windows.h>
#include <string>

#include "G3DOleInPlaceFrame.h"
#include "G3DOleInPlaceSite.h"
#include "G3DDocHostUiHandler.h"
#include "G3DOleClientSite.h"

#include <ExDisp.h>


namespace G3D
{

class Browser
{
private:
static Browser* msSingleton;
WideString mFilePath;

private:
HWND mMainWindow;
HWND hwndProgress;
IOleObject* mBrowserObject;
IWebBrowser2* mWebBrowser;
OleInPlaceFrame* inPlaceFrame;
OleInPlaceSite* inPlaceSite;
DocHostUiHandler* docHostUiHandler;
OleClientSite* clientSite;

public:
static Browser& getSingleton();
static Browser* getSingletonPtr();

private:
static LRESULT CALLBACK windowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

public:
Browser();
virtual ~Browser();

WideString openBrowser(HINSTANCE hInstance, const WideString& filePath, HWND parentWindow);
void closeBrowser(){DestroyWindow(mMainWindow);}

private:
void setBrowserObject(IOleObject* browserObj);
void setWebBrowser(IWebBrowser2* webBrowser);
};
}
#endif // __G3DBROWSER_H__
106 changes: 106 additions & 0 deletions G3DWarehouseBrowser/include/G3DDocHostUiHandler.h
@@ -0,0 +1,106 @@
/*
Copyright (c) 2009 NetAllied Systems GmbH
This file is part of G3DWarehouseBrowser.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/

#ifndef __G3D_DOC_HOST_UI_HANDLER_H__
#define __G3D_DOC_HOST_UI_HANDLER_H__

#include "G3DPrerequisites.h"
#include <mshtml.h>
#include <mshtmhst.h>
#include <oaidl.h>
#include <string>

namespace G3D
{
static const wchar_t* URL_START_STRING = L"skp:getSkp@";
static const wchar_t* FILE_PATH = L"C:\\Temp\\test.zip";

class DocHostUiHandler : public IDocHostUIHandler {

private:
IOleClientSite* mClientSite;
HWND mHwndProgress;
WideString& mFilePath;

public:
DocHostUiHandler(HWND hwndProgress, WideString& filePath)
: mHwndProgress(hwndProgress)
, mFilePath(filePath)
, mClientSite(0) {};
virtual ~DocHostUiHandler() { mClientSite->Release(); }
void setClientSite(IOleClientSite*);
HRESULT cancelNavigation(OLECHAR __RPC_FAR* __RPC_FAR* ppchURLOut);

public: // IDocHostUIHandler interface
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID FAR* ppvObj) {
if (mClientSite) {
return mClientSite->QueryInterface(riid, ppvObj);
}
return E_NOINTERFACE;
}

ULONG STDMETHODCALLTYPE AddRef() { return 1; }

ULONG STDMETHODCALLTYPE Release() { return 1; }

HRESULT STDMETHODCALLTYPE ShowContextMenu(
DWORD dwID,
POINT __RPC_FAR *ppt,
IUnknown __RPC_FAR *pcmdtReserved,
IDispatch __RPC_FAR *pdispReserved){ return S_OK; }

HRESULT STDMETHODCALLTYPE ShowUI(
DWORD dwID,
IOleInPlaceActiveObject __RPC_FAR *pActiveObject,
IOleCommandTarget __RPC_FAR *pCommandTarget,
IOleInPlaceFrame __RPC_FAR *pFrame,
IOleInPlaceUIWindow __RPC_FAR *pDoc) { return S_OK; }

HRESULT STDMETHODCALLTYPE GetHostInfo(DOCHOSTUIINFO __RPC_FAR *pInfo);

HRESULT STDMETHODCALLTYPE HideUI() { return S_OK; }

HRESULT STDMETHODCALLTYPE UpdateUI() { return S_OK; }

HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable) { return S_FALSE; }

HRESULT STDMETHODCALLTYPE OnDocWindowActivate(BOOL fActivate) { return S_OK; }

HRESULT STDMETHODCALLTYPE OnFrameWindowActivate(BOOL fActivate) { return S_OK; }

HRESULT STDMETHODCALLTYPE ResizeBorder(LPCRECT prcBorder, IOleInPlaceUIWindow __RPC_FAR *pUIWindow, BOOL fRameWindow) { return S_OK; }

HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG lpMsg, const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID)
{
pguidCmdGroup = 0;
return S_FALSE;
}

HRESULT STDMETHODCALLTYPE GetOptionKeyPath(LPOLESTR __RPC_FAR *pchKey, DWORD dw) { return S_FALSE; }

HRESULT STDMETHODCALLTYPE GetDropTarget(IDropTarget __RPC_FAR *pDropTarget, IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget)
{ return S_FALSE; }

HRESULT STDMETHODCALLTYPE GetExternal(IDispatch __RPC_FAR *__RPC_FAR *ppDispatch){
*ppDispatch = 0;
return S_FALSE;
}

HRESULT STDMETHODCALLTYPE TranslateUrl(DWORD dwTranslate, OLECHAR __RPC_FAR *pchURLIn, OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);

HRESULT STDMETHODCALLTYPE FilterDataObject(IDataObject __RPC_FAR *pDO, IDataObject __RPC_FAR *__RPC_FAR *ppDORet) {

NOTIMPLEMENTED;
//*ppDORet = 0;
//return S_FALSE;
}
};
}
#endif // __G3D_DOC_HOST_UI_HANDLER_H__
40 changes: 40 additions & 0 deletions G3DWarehouseBrowser/include/G3DDownloadFile.h
@@ -0,0 +1,40 @@
/*
Copyright (c) 2009 NetAllied Systems GmbH
This file is part of G3DWarehouseBrowser.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/

#ifndef __G3D_DOWNLOAD_FILE_H__
#define __G3D_DOWNLOAD_FILE_H__

#include "G3DPrerequisites.h"
#include <urlmon.h>
#pragma comment(lib,"urlmon") // link against urlmon.lib

#include "G3DDownloadStatusCallback.h"

class DownloadFile
{
public:
void getFile( const wchar_t* url, const wchar_t* fileName, HWND hwndProgress )
{
// initialize COM
if ( FAILED( CoInitialize(NULL) ) ) {
return;
}

DownloadStatusCallback callback(hwndProgress);
HRESULT hResult = URLDownloadToFile(
NULL, url, fileName, 0, &callback );

CoUninitialize();
if ( FAILED(hResult) ) {
return;
}
}
};
#endif // __G3D_DOWNLOAD_FILE_H__
51 changes: 51 additions & 0 deletions G3DWarehouseBrowser/include/G3DDownloadStatusCallback.h
@@ -0,0 +1,51 @@
/*
Copyright (c) 2009 NetAllied Systems GmbH
This file is part of G3DWarehouseBrowser.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/

#ifndef __G3D_DOWNLOAD_STATUS_CALLBACK_H__
#define __G3D_DOWNLOAD_STATUS_CALLBACK_H__

class DownloadStatusCallback : public IBindStatusCallback
{
private:
HWND hwndProgress;
double stepFactor;

public:
DownloadStatusCallback(HWND hwndProgress):hwndProgress(hwndProgress){};
virtual ~DownloadStatusCallback(){};

// IBindStatusCallback methods. Note that the only method called by IE
// is OnProgress()
STDMETHOD(OnStartBinding)(DWORD dwReserved, IBinding __RPC_FAR *pib) { return E_NOTIMPL; }

STDMETHOD(GetPriority)( LONG __RPC_FAR *pnPriority ) { return E_NOTIMPL; }

STDMETHOD(OnLowResource)( DWORD reserved ) { return E_NOTIMPL; }

STDMETHOD(OnProgress)( ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR wszStatusText);

STDMETHOD(OnStopBinding)( HRESULT hresult, LPCWSTR szError) { return E_NOTIMPL; }

STDMETHOD(GetBindInfo)( DWORD __RPC_FAR *grfBINDF, BINDINFO __RPC_FAR *pbindinfo) { return E_NOTIMPL; }

STDMETHOD(OnDataAvailable)( DWORD grfBSCF, DWORD dwSize, FORMATETC __RPC_FAR *pformatetc, STGMEDIUM __RPC_FAR *pstgmed)
{ return E_NOTIMPL; }

STDMETHOD(OnObjectAvailable)( REFIID riid, IUnknown __RPC_FAR *punk) { return E_NOTIMPL; }



STDMETHOD_(ULONG,AddRef)() { return 0; }
STDMETHOD_(ULONG,Release)() { return 0; }
STDMETHOD(QueryInterface)( REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject) { return E_NOTIMPL; }
};


#endif // __G3D_DOWNLOAD_STATUS_CALLBACK_H__
60 changes: 60 additions & 0 deletions G3DWarehouseBrowser/include/G3DFileUnzipper.h
@@ -0,0 +1,60 @@
/*
Copyright (c) 2009 NetAllied Systems GmbH
This file is part of G3DWarehouseBrowser.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/

#ifndef ___G3D_FILEUNZIPPER_H__
#define ___G3D_FILEUNZIPPER_H__

#include "G3DPrerequisites.h"
#include <string>


namespace G3D
{
/** Extracts the model (model.dae) and all the images of a zip file, downloaded from the
google 3d Warehouse.*/
class FileUnzipper
{
private:
String mLastErrorString;

String mDAEFilePath;

/** True, if unzipping succeeded.*/
bool mSucceeded;

public:
/** Constructor. Extracts the model and the images contained in @a zipFile into the
directory @a extractPath. @a extractPath must exist.*/
FileUnzipper( const String& zipFile, const String& extractPath );
virtual ~FileUnzipper();

/** Returns the path to the model.dae file.*/
String getDAEFilePath() const { return mDAEFilePath; };

/** True, if unzipping succeeded.*/
bool getSucceeded() const { return mSucceeded; }

/** Returns the error string of the last error that occurred.*/
const String& getLastErrorString() const { return mLastErrorString; }


// private function declarations
private:
/** Disable default copy ctor. */
FileUnzipper( const FileUnzipper& pre );
/** Disable default assignment operator. */
const FileUnzipper& operator= ( const FileUnzipper& pre );

bool unzipFile( const String& zipFile, const String& extractPath );

};
} // namespace

#endif // ___G3D_FILEUNZIPPER_H__

0 comments on commit eab47d4

Please sign in to comment.