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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/CONCEPT/classTest.h>
#include <BALLTestConfig.h>
///////////////////////////
#include <BALL/VIEW/KERNEL/representationManager.h>
#include <BALL/VIEW/KERNEL/mainControl.h>
#include <BALL/VIEW/KERNEL/clippingPlane.h>
#include <BALL/VIEW/DIALOGS/displayProperties.h>
#include <BALL/KERNEL/system.h>
///////////////////////////
/////////////////////////////////////////////////////////////
START_TEST(RepresentationManager)
/////////////////////////////////////////////////////////////
using namespace BALL;
using namespace BALL::VIEW;
using namespace std;
char* argv = "asd";
int args = 0;
// need a valid X-Context for the following code:
// QApplication app(args, &argv);
// MainControl mc;
// DisplayProperties* dp = new DisplayProperties(&mc);
// dp->initializeWidget(mc);
// dp->initializePreferencesTab(*mc.getPreferences());
CHECK(CSTR)
RepresentationManager rm;
RESULT
CHECK(RepresentationManager::BALL_CREATE(RepresentationManager))
// no copying support
RESULT
CHECK(RepresentationManager::RepresentationManager& operator = (const RepresentationManager& pm) throw())
// no copying support
RESULT
/*
CHECK(RepresentationManager::bool operator == (const RepresentationManager& pm) const throw())
RepresentationManager r1(&mc), r2(&mc);
TEST_EQUAL(r1 == r2, true)
Representation* rep = new Representation();
r1.insert(*rep);
TEST_EQUAL(r1 == r2, false)
RESULT
RepresentationManager rm(&mc);
*/
RepresentationManager rm;
CHECK(RepresentationManager::clear() throw())
rm.insert(*new Representation());
TEST_EQUAL(rm.getNumberOfRepresentations(), 1)
rm.clear();
TEST_EQUAL(rm.getNumberOfRepresentations(), 0)
RESULT
CHECK(RepresentationManager::remove(Representation& representation, bool send_message = true) throw())
Representation* rep = new Representation();
rm.insert(*rep);
TEST_EQUAL(rm.getNumberOfRepresentations(), 1)
rm.remove(*rep);
TEST_EQUAL(rm.getNumberOfRepresentations(), 0)
RESULT
CHECK(RepresentationManager::insert(Representation& representation, bool send_message = true) throw())
Representation* rep = new Representation();
rm.insert(*rep);
TEST_EQUAL(rm.getNumberOfRepresentations(), 1)
rm.clear();
RESULT
CHECK(RepresentationManager::getRepresentations() const throw())
Representation* rep = new Representation();
rm.clear();
rm.insert(*rep);
TEST_EQUAL(*rm.getRepresentations().begin(), rep)
rm.clear();
TEST_EQUAL(rm.getRepresentations().size(), 0)
RESULT
CHECK(RepresentationManager::createRepresentation() throw())
Representation* rep = rm.createRepresentation();
TEST_EQUAL(*rm.getRepresentations().begin(), rep);
RESULT
CHECK(RepresentationManager::has(const Representation& representation) const throw())
Representation* rep = new Representation;
TEST_EQUAL(rm.has(*rep), false)
rm.clear();
rm.insert(*rep);
TEST_EQUAL(rm.has(*rep), true)
RESULT
CHECK(RepresentationManager::dump(std::ostream& s, Size depth) const throw())
rm.clear();
Representation* rep = new Representation;
rm.insert(*rep);
String filename;
NEW_TMP_FILE(filename)
std::ofstream outfile(filename.c_str(), std::ios::out);
rm.dump(outfile);
outfile.close();
TEST_FILE_REGEXP(filename.c_str(), BALL_TEST_DATA_PATH(RepresentationManager.txt))
RESULT
CHECK(RepresentationManager::begin() throw())
rm.clear();
TEST_EQUAL(rm.begin() == rm.getRepresentations().end(), true)
Representation* rep = rm.createRepresentation();
TEST_EQUAL(*rm.begin(), rep)
RESULT
CHECK(RepresentationManager::end() throw())
rm.clear();
TEST_EQUAL(rm.begin() == rm.getRepresentations().end(), true)
RESULT
Composite composite;
List<const Composite*> cl;
cl.push_back(&composite);
CHECK(RepresentationManager::removedComposite(const Composite& composite, bool update = true) throw())
rm.clear();
Representation* rep = rm.createRepresentation();
rep->setComposites(cl);
Representation* rep2 = rm.createRepresentation();
TEST_EQUAL(rm.getNumberOfRepresentations(), 2)
rm.removedComposite(composite);
TEST_EQUAL(rm.getNumberOfRepresentations(), 1)
TEST_EQUAL(*rm.begin(), rep2);
RESULT
CHECK(RepresentationManager::getRepresentationsOf(const Composite& composite) throw())
rm.clear();
Representation* rep = rm.createRepresentation();
rep->setComposites(cl);
Representation* rep2 = rm.createRepresentation();
TEST_EQUAL(rm.getRepresentationsOf(composite).size(), 1)
TEST_EQUAL(*rm.getRepresentationsOf(composite).begin(), rep)
rm.remove(*rep2);
RESULT
CHECK(RepresentationManager::rebuildAllRepresentations() throw())
rm.clear();
Representation* rep = rm.createRepresentation();
rm.rebuildAllRepresentations();
TEST_EQUAL(rm.willBeUpdated(*rep), true)
Representation* rep2 = rm.createRepresentation();
TEST_EQUAL(rm.willBeUpdated(*rep2), false)
RESULT
CHECK(RepresentationManager::getClippingPlanes() const )
TEST_EQUAL(rm.getClippingPlanes().size(), 0)
RESULT
CHECK(removeClippingPlane(ClippingPlane*))
ClippingPlane pl;
TEST_EQUAL(rm.removeClippingPlane(&pl), false)
RESULT
CHECK(insertClippingPlane(ClippingPlane*))
ClippingPlane* plane = new ClippingPlane();
rm.insertClippingPlane(plane);
TEST_EQUAL(*rm.getClippingPlanes().begin(), plane)
rm.removeClippingPlane(plane);
TEST_EQUAL(rm.getClippingPlanes().size(), 0)
RESULT
/*
Representation rrep;
ClippingPlane rplane;
RepresentationManager& mrm = mc.getRepresentationManager();
System* system = new System();
CHECK(storeRepresentations(INIFile&))
mc.insert(*system);
List<const Composite*> cl;
cl.push_back(system);
mrm.clear();
Representation* rep = mrm.createRepresentation();
rep->setComposites(cl);
rep->setModelType(MODEL_SE_SURFACE);
rep->setColoringMethod(COLORING_TEMPERATURE_FACTOR);
rep->setTransparency(100);
rep->setDrawingMode(DRAWING_MODE_WIREFRAME);
rep->setHidden(true);
rrep = *rep;
rplane.setPoint(Vector3(1,2,3));
rplane.setNormal(Vector3(4,5,6));
rplane.setCappingEnabled(true);
rplane.setActive(true);
mrm.insertClippingPlane(new ClippingPlane(rplane));
String filename;
NEW_TMP_FILE(filename)
INIFile file(filename);
mrm.storeRepresentations(file);
file.write();
TEST_FILE(filename.c_str(), BALL_TEST_DATA_PATH(RepresentationManager2.txt))
RESULT
CHECK(restoreRepresentations(const INIFile& in, const vector<const Composite*>& new_systems))
mrm.clear();
INIFile infile(BALL_TEST_DATA_PATH(RepresentationManager2.txt));
infile.read();
vector<const Composite*> new_systems;
new_systems.push_back(system);
mrm.clear();
TEST_EQUAL(mrm.getNumberOfRepresentations(), 0);
mrm.restoreRepresentations(infile, new_systems);
TEST_EQUAL(mrm.getNumberOfRepresentations(), 1);
if (mrm.getNumberOfRepresentations() == 1)
{
Representation& rep = **mrm.begin();
TEST_EQUAL(rep.getModelType(), rrep.getModelType())
TEST_EQUAL(rep.getColoringMethod(), rrep.getColoringMethod())
TEST_EQUAL(rep.getTransparency(), rrep.getTransparency())
TEST_EQUAL(rep.getDrawingMode(), rrep.getDrawingMode())
TEST_EQUAL(rep.isHidden(), rrep.isHidden())
}
TEST_EQUAL(mrm.getClippingPlanes().size(), 1)
if (mrm.getClippingPlanes().size() == 1)
{
ClippingPlane* tp = *mrm.getClippingPlanes().begin();
TEST_EQUAL(tp->getNormal(), rplane.getNormal())
TEST_EQUAL(tp->getPoint(), rplane.getPoint())
TEST_EQUAL(tp->cappingEnabled(), rplane.cappingEnabled())
}
RESULT
*/
CHECK(focusRepresentation(const Representation&))
RESULT
CHECK(willBeUpdated(const Representation&) const)
RESULT
CHECK(updateRunning())
RESULT
CHECK(startedRendering(Representation*))
RESULT
CHECK(finishedRendering(Representation*))
RESULT
CHECK(isBeeingRendered(const Representation*) const)
RESULT
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST
|