<commit_before>#include "../include/windows/View.h"

// view constructor
View::View(Model* m, int x, int y, int w, int h, const char *label) :
	RenderWindow(x,y,w,h) {
	
	// set OSG viewport
    this->getCamera()->setViewport(new osg::Viewport(0,0,w,h));
    
    // get the graphics context
    this->getCamera()->setGraphicsContext(this->getGraphicsWindow());
    
    // do single-threaded view
   this->setThreadingModel(osgViewer::Viewer::SingleThreaded);
   
   // set the model
   this->model = m;
   
   // initialize the root node
   this->root = new osg::Group();
   
   // initialize the ground
   this->ground = new Ground( 400.0f );
   
   // add the ground to the root node
   this->root->addChild( this->ground.get() );
	
	// set the key modifiers to false
   this->modifiers = map< int, bool >();
   this->modifiers[ FL_SHIFT ] = false;
   this->modifiers[ FL_CTRL ] = false;
   this->modifiers[ FL_ALT ] = false;
   this->modifiers[ FL_META ] = false;
   
   // set up the object map
   this->objectMap = map< bz2object*, osg::ref_ptr< Renderable > >();
	
	// build the scene from the model
	vector<bz2object*> objects = this->model->getObjects();
	if(objects.size() > 0) {
		for(vector<bz2object*>::iterator i = objects.begin(); i != objects.end(); i++) {
			osg::ref_ptr< Renderable > r = (*i)->makeRenderable();
			bool result = this->root->addChild( r.get() );
			if(result)
				this->objectMap[ *i ] = r;
		}
	}
	
	
   // make a new selection object
   this->selection = new Selection();
   
	// add the root node to the scene
   this->setSceneData( this->root.get() );
   
   // give the View a trackball manipulator
   osgGA::TrackballManipulator* cameraManipulator = new osgGA::TrackballManipulator();
   
   this->setCameraManipulator(cameraManipulator);
   
   // make an event handler collection
   this->eventHandlers = new EventHandlerCollection( this );
   
   // add the selectHandler
   this->eventHandlers->addEventHandler( selectHandler::getName().c_str(), new selectHandler( this, cameraManipulator ) );
   
   // add the scene picker event handler
   this->addEventHandler(eventHandlers.get());
   
}

// destructor
View::~View() { }


// draw method (really simple)
void View::draw(void) {
	this->frame();
}

// handle events
int View::handle(int event) {
	// whatever the event was, we need to regenerate the modifier keys
	int shiftState = Fl::event_state();
	this->modifiers[ FL_SHIFT ] = ( shiftState & FL_SHIFT );
	this->modifiers[ FL_CTRL ] = ( shiftState & FL_CTRL );
	this->modifiers[ FL_META ] = ( shiftState & FL_META );
	this->modifiers[ FL_ALT ] = ( shiftState & FL_ALT );
	
	this->keydown = Fl::event_key();
	this->buttondown = Fl::event_button();
            
	// forward FLTK events to OSG
	switch(event){
        case FL_PUSH:
        	// handle single mouse clicks
        	if(Fl::event_clicks() == 0) {
        		_gw->getEventQueue()->mouseButtonPress(Fl::event_x(), Fl::event_y(), Fl::event_button() );
        	}
        	// handle double clicks
            else {
            	_gw->getEventQueue()->mouseDoubleButtonPress(Fl::event_x(), Fl::event_y(), Fl::event_button() );<commit_msg>more implicit casts to bool<commit_after>#include "../include/windows/View.h"

// view constructor
View::View(Model* m, int x, int y, int w, int h, const char *label) :
	RenderWindow(x,y,w,h) {
	
	// set OSG viewport
    this->getCamera()->setViewport(new osg::Viewport(0,0,w,h));
    
    // get the graphics context
    this->getCamera()->setGraphicsContext(this->getGraphicsWindow());
    
    // do single-threaded view
   this->setThreadingModel(osgViewer::Viewer::SingleThreaded);
   
   // set the model
   this->model = m;
   
   // initialize the root node
   this->root = new osg::Group();
   
   // initialize the ground
   this->ground = new Ground( 400.0f );
   
   // add the ground to the root node
   this->root->addChild( this->ground.get() );
	
	// set the key modifiers to false
   this->modifiers = map< int, bool >();
   this->modifiers[ FL_SHIFT ] = false;
   this->modifiers[ FL_CTRL ] = false;
   this->modifiers[ FL_ALT ] = false;
   this->modifiers[ FL_META ] = false;
   
   // set up the object map
   this->objectMap = map< bz2object*, osg::ref_ptr< Renderable > >();
	
	// build the scene from the model
	vector<bz2object*> objects = this->model->getObjects();
	if(objects.size() > 0) {
		for(vector<bz2object*>::iterator i = objects.begin(); i != objects.end(); i++) {
			osg::ref_ptr< Renderable > r = (*i)->makeRenderable();
			bool result = this->root->addChild( r.get() );
			if(result)
				this->objectMap[ *i ] = r;
		}
	}
	
	
   // make a new selection object
   this->selection = new Selection();
   
	// add the root node to the scene
   this->setSceneData( this->root.get() );
   
   // give the View a trackball manipulator
   osgGA::TrackballManipulator* cameraManipulator = new osgGA::TrackballManipulator();
   
   this->setCameraManipulator(cameraManipulator);
   
   // make an event handler collection
   this->eventHandlers = new EventHandlerCollection( this );
   
   // add the selectHandler
   this->eventHandlers->addEventHandler( selectHandler::getName().c_str(), new selectHandler( this, cameraManipulator ) );
   
   // add the scene picker event handler
   this->addEventHandler(eventHandlers.get());
   
}

// destructor
View::~View() { }


// draw method (really simple)
void View::draw(void) {
	this->frame();
}

// handle events
int View::handle(int event) {
	// whatever the event was, we need to regenerate the modifier keys
	int shiftState = Fl::event_state();
	this->modifiers[ FL_SHIFT ] = (( shiftState & FL_SHIFT ) != 0);
	this->modifiers[ FL_CTRL ] = (( shiftState & FL_CTRL ) != 0);
	this->modifiers[ FL_META ] = (( shiftState & FL_META ) != 0);
	this->modifiers[ FL_ALT ] = (( shiftState & FL_ALT ) != 0);
	
	this->keydown = Fl::event_key();
	this->buttondown = Fl::event_button();
            
	// forward FLTK events to OSG
	switch(event){
        case FL_PUSH:
        	// handle single mouse clicks
        	if(Fl::event_clicks() == 0) {
        		_gw->getEventQueue()->mouseButtonPress(Fl::event_x(), Fl::event_y(), Fl::event_button() );
        	}
        	// handle double clicks
            else {
            	_gw->getEventQueue()->mouseDoubleButtonPress(Fl::event_x(), Fl::event_y(), Fl::event_button() );
{'fraction_non_alphanumeric': 0.15323854660347552, 'fraction_numerical': 0.004107424960505529, 'mean_word_length': 3.1569271175311884, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2799966', 'n_tokens_mistral': 2122, 'n_tokens_neox': 2052, 'n_words': 500}