1 #pragma once
2 /****************************************************************************
3  *      session.h: YafaRay Session control
4  *      This is part of the yafray package
5  *		Copyright (C) 2016 David Bluecame
6  * 		Session control and persistent objects between renders
7  *
8  *      This library is free software; you can redistribute it and/or
9  *      modify it under the terms of the GNU Lesser General Public
10  *      License as published by the Free Software Foundation; either
11  *      version 2.1 of the License, or (at your option) any later version.
12  *
13  *      This library is distributed in the hope that it will be useful,
14  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *      Lesser General Public License for more details.
17  *
18  *      You should have received a copy of the GNU Lesser General Public
19  *      License along with this library; if not, write to the Free Software
20  *      Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22 
23 #ifndef Y_SESSION_H
24 #define Y_SESSION_H
25 
26 #include <yafray_constants.h>
27 #include <utilities/threadUtils.h>
28 
29 __BEGIN_YAFRAY
30 
31 class photonMap_t;
32 
33 class YAFRAYCORE_EXPORT session_t
34 {
35 	public:
36 		session_t();
37 		session_t(const session_t&);	//customizing copy constructor so we can use a std::mutex as a class member (not copiable)
38 
39 		~session_t();
40 
41 		void setStatusRenderStarted();
42 		void setStatusRenderResumed();
43 		void setStatusRenderFinished();
44 		void setStatusRenderAborted();
45 		void setStatusTotalPasses(int total_passes);
46 		void setStatusCurrentPass(int current_pass);
47 		void setStatusCurrentPassPercent(float current_pass_percent);
48 		void setInteractive(bool interactive);
49 		void setPathYafaRayXml(std::string path);
50 		void setPathImageOutput(std::string path);
setDifferentialRaysEnabled(bool value)51 		void setDifferentialRaysEnabled(bool value) { mRayDifferentialsEnabled = value; }
52 
53 		bool renderInProgress();
54 		bool renderResumed();
55 		bool renderFinished();
56 		bool renderAborted();
getDifferentialRaysEnabled()57 		bool getDifferentialRaysEnabled() const { return mRayDifferentialsEnabled; }
58 
59 		int totalPasses();
60 		int currentPass();
61 		float currentPassPercent();
62 		bool isInteractive();
63 		std::string getPathYafaRayXml();
64 		std::string getPathImageOutput();
65 
66 		photonMap_t * causticMap = nullptr;
67 		photonMap_t * diffuseMap = nullptr;
68 		photonMap_t * radianceMap = nullptr;
69 
70 		std::mutex mutx;
71 
72 	protected:
73 		bool mRenderInProgress = false;
74 		bool mRenderFinished = false;
75 		bool mRenderResumed = false;
76 		bool mRenderAborted = false;
77 		bool mRayDifferentialsEnabled = false;  //!< By default, disable ray differential calculations. Only if at least one texture uses them, then enable differentials. This should avoid the (many) extra calculations when they are not necessary.
78 		int mTotalPasses = 0;
79 		int mCurrentPass = 0;
80 		float mCurrentPassPercent = 0.f;
81 		bool mInteractive = false;
82 		std::string mPathYafaRayXml;
83 		std::string mPathImageOutput;
84 };
85 
86 extern YAFRAYCORE_EXPORT session_t session;
87 
88 __END_YAFRAY
89 
90 #endif
91