Exemple #1
0
ItemBase* ScenePickingHandler::pick(const QPoint& point)
{
    if (!m_project.has_trace_context())
    {
        RENDERER_LOG_INFO("the scene must be rendering or must have been rendered at least once for picking to be available.");
        return 0;
    }

    const Vector2i pix = m_mouse_tracker.widget_to_pixel(point);
    const Vector2d ndc = m_mouse_tracker.widget_to_ndc(point);

    const ScenePicker scene_picker(m_project);
    const ScenePicker::PickingResult result = scene_picker.pick(ndc);

    stringstream sstr;

    sstr << "picking details:" << endl;
    sstr << "  pixel coords     " << pix.x << ", " << pix.y << endl;
    sstr << "  ndc coords       " << ndc.x << ", " << ndc.y << endl;
    sstr << "  world coords     " << result.m_point.x << ", " << result.m_point.y << ", " << result.m_point.z << endl;
    sstr << "  depth            " << result.m_distance << endl;
    sstr << "  primitive type   " << get_primitive_type_name(result.m_primitive_type) << endl;

    sstr << print_entity("  camera           ", result.m_camera) << endl;
    sstr << print_entity("  assembly inst.   ", result.m_assembly_instance) << endl;
    sstr << print_entity("  assembly         ", result.m_assembly) << endl;
    sstr << print_entity("  object inst.     ", result.m_object_instance) << endl;
    sstr << print_entity("  object           ", result.m_object) << endl;
    sstr << print_entity("  material         ", result.m_material) << endl;
    sstr << print_entity("  surface shader   ", result.m_surface_shader) << endl;
    sstr << print_entity("  bsdf             ", result.m_bsdf) << endl;
    sstr << print_entity("  bssrdf           ", result.m_bssrdf) << endl;
    sstr << print_entity("  edf              ", result.m_edf);

    RENDERER_LOG_INFO("%s", sstr.str().c_str());

    emit signal_entity_picked(result);

    const QString picking_mode =
        m_picking_mode_combo->itemData(m_picking_mode_combo->currentIndex()).value<QString>();
    const Entity* picked_entity = get_picked_entity(result, picking_mode);

    ItemBase* item;

    if (picked_entity)
    {
        item = m_project_explorer.select_entity(picked_entity->get_uid());
    }
    else
    {
        m_project_explorer.clear_selection();
        item = 0;
    }

    m_widget->setFocus();

    return item;
}
int get_row() {
  char *crow[MAX_FIELDS];
  char token[MAX_TOKEN+1];
  int status;
  int colcount;
  int i;

  colcount=0;
  status=1;
  memset(&crow,0,sizeof(crow));
  while(colcount<MAX_FIELDS && status>0) {
    status=get_csv_token((char*)&token,MAX_TOKEN);
    if(status<0) { break; }
    crow[colcount]=new char[strlen(token)+1];
    strcpy(crow[colcount],token);
    colcount++;
    }

  if(colcount==0) {
    cleanup();
    exit(0);
    }
  if(colcount==MAX_FIELDS) {
    fatal("Row contained more fields than this sofware can handle");
    }
  if(colcount!=fieldcount) {
    warn("Row count does not match field count");
    return(status);
    }

  printf("<row>\n");
  for(i=0;i<colcount;i++) {
    if(nullify==0 || crow[i][0]!='\0') {
      if(xmlmode==1) {
        printf("  <%s value=\"",fields[i]);
        print_entity(crow[i]);
        printf("\" />\n");
        }
      else if(xmlmode==2) {
        printf("  <item name=\"%s\">",fields[i]);
        print_entity(crow[i]);
        printf("</item>\n");
        }
      else {
        printf("  <%s>",fields[i]);
        print_entity(crow[i]);
        printf("</%s>\n",fields[i]);
        }
      }
    delete crow[i];
    crow[i]=NULL;
    }
  printf("</row>\n");


  return(status);
  }
Exemple #3
0
static void print_context(const context_t *context)
{
	for (entity_t *entity = context->entities; entity != NULL;
	     entity = entity->base.next) {
		print_entity(entity);
	}

	concept_instance_t *instance = context->concept_instances;
	for ( ; instance != NULL; instance = instance->next) {
		print_concept_instance(instance);
	}
}
void ScenePickingHandler::pick(const QPoint& point)
{
    if (!m_project.has_trace_context())
    {
        RENDERER_LOG_INFO("the scene must be rendering or must have been rendered at least once for picking to be available.");
        return;
    }

    const Vector2i pix = m_mouse_tracker.widget_to_pixel(point);
    const Vector2d ndc = m_mouse_tracker.widget_to_ndc(point);

    const ScenePicker scene_picker(m_project.get_trace_context());
    const ScenePicker::PickingResult result = scene_picker.pick(ndc);

    stringstream sstr;

    sstr << "picking details:" << endl;
    sstr << "  pixel coords     " << pix.x << ", " << pix.y << endl;
    sstr << "  ndc coords       " << ndc.x << ", " << ndc.y << endl;

    print_entity(sstr, "  camera           ", result.m_camera);
    print_entity(sstr, "  assembly inst.   ", result.m_assembly_instance);
    print_entity(sstr, "  assembly         ", result.m_assembly);
    print_entity(sstr, "  object inst.     ", result.m_object_instance);
    print_entity(sstr, "  object           ", result.m_object);
    print_entity(sstr, "  material         ", result.m_material);
    print_entity(sstr, "  surface shader   ", result.m_surface_shader);
    print_entity(sstr, "  bsdf             ", result.m_bsdf);
    print_entity(sstr, "  edf              ", result.m_edf);

    RENDERER_LOG_INFO("%s", sstr.str().c_str());

    const QString picking_mode =
        m_picking_mode_combo->itemData(m_picking_mode_combo->currentIndex()).value<QString>();

    const Entity* picked_entity = get_picked_entity(result, picking_mode);

    if (picked_entity)
        m_project_explorer.highlight_entity(picked_entity->get_uid());
    else m_project_explorer.clear_highlighting();
}
Exemple #5
0
void print_compound_definition(const compound_t *compound)
{
	print_string("{\n");
	change_indent(1);

	for (entity_t const *entity = compound->members.first_entity;
	     entity != NULL; entity = entity->base.next) {
		if (entity->kind != ENTITY_COMPOUND_MEMBER)
			continue;

		print_indent();
		print_entity(entity);
		print_char('\n');
	}

	change_indent(-1);
	print_indent();
	print_char('}');
	print_modifiers(compound->modifiers);
}
Exemple #6
0
void draw_board(void) {
    clear();
    move(0, 0);
    for (int x = -1; x < WIDTH; x++)
        printw("=");
    printw("=\n");
    for (int y = 0; y < HEIGHT; y++) {
        printw("|");
        for (int x = 0; x < WIDTH; x++)
            printw(" ");
        printw("|\n");
    }
    for (int x = -1; x < WIDTH; x++)
        printw("=");
    printw("=\n");
    print_entity(player);
    monster_list_map(monsters, print_entity);
    print_info();
    refresh();
}
Exemple #7
0
void print_compound_definition(const compound_t *compound)
{
	print_string("{\n");
	change_indent(1);

	entity_t *entity = compound->members.entities;
	for ( ; entity != NULL; entity = entity->base.next) {
		if (entity->kind != ENTITY_COMPOUND_MEMBER)
			continue;

		print_indent();
		print_entity(entity);
		print_char('\n');
	}

	change_indent(-1);
	print_indent();
	print_char('}');
	if (compound->modifiers & DM_TRANSPARENT_UNION) {
		print_string("__attribute__((__transparent_union__))");
	}
}
ItemBase* ScenePickingHandler::pick(const QPoint& point)
{
    if (!m_project.has_trace_context())
    {
        RENDERER_LOG_INFO("the scene must be rendering or must have been rendered at least once for picking to be available.");
        return nullptr;
    }

    const Vector2i pix = m_mouse_tracker.widget_to_pixel(point);
    const Vector2d ndc = m_mouse_tracker.widget_to_ndc(point);

    const ScenePicker scene_picker(m_project);
    const ScenePicker::PickingResult result = scene_picker.pick(ndc);

    stringstream sstr;

    sstr << "picking details:" << endl;

    sstr << "  pixel coordinates             " << pix << endl;
    sstr << "  ndc coordinates               " << ndc << endl;
    sstr << "  primitive type                " << get_primitive_type_name(result.m_primitive_type) << endl;
    sstr << "  distance                      " << result.m_distance << endl;

    sstr << "  barycentric coordinates       " << filter_neg_zero(result.m_bary) << endl;
    sstr << "  uv coordinates                " << filter_neg_zero(result.m_uv) << endl;
    sstr << "  duvdx                         " << filter_neg_zero(result.m_duvdx) << endl;
    sstr << "  duvdy                         " << filter_neg_zero(result.m_duvdy) << endl;
    sstr << "  point                         " << filter_neg_zero(result.m_point) << endl;
    sstr << "  dpdu                          " << filter_neg_zero(result.m_dpdu) << endl;
    sstr << "  dpdv                          " << filter_neg_zero(result.m_dpdv) << endl;
    sstr << "  dndu                          " << filter_neg_zero(result.m_dndu) << endl;
    sstr << "  dndv                          " << filter_neg_zero(result.m_dndv) << endl;
    sstr << "  dpdx                          " << filter_neg_zero(result.m_dpdx) << endl;
    sstr << "  dpdy                          " << filter_neg_zero(result.m_dpdy) << endl;
    sstr << "  geometric normal              " << filter_neg_zero(result.m_geometric_normal) << endl;
    sstr << "  shading normal                " << filter_neg_zero(result.m_original_shading_normal) << endl;
    sstr << "  side                          " << get_side_name(result.m_side) << endl;

    sstr << print_entity("  camera                        ", result.m_camera) << endl;
    sstr << print_entity("  assembly instance             ", result.m_assembly_instance) << endl;
    sstr << print_entity("  assembly                      ", result.m_assembly) << endl;
    sstr << print_entity("  object instance               ", result.m_object_instance) << endl;
    sstr << print_entity("  object                        ", result.m_object) << endl;
    sstr << print_entity("  material                      ", result.m_material) << endl;
    sstr << print_entity("  surface shader                ", result.m_surface_shader) << endl;
    sstr << print_entity("  bsdf                          ", result.m_bsdf) << endl;
    sstr << print_entity("  bssrdf                        ", result.m_bssrdf) << endl;
    sstr << print_entity("  edf                           ", result.m_edf);

    RENDERER_LOG_INFO("%s", sstr.str().c_str());

    emit signal_entity_picked(result);

    const QString picking_mode =
        m_picking_mode_combo->itemData(m_picking_mode_combo->currentIndex()).value<QString>();
    const Entity* picked_entity = get_picked_entity(result, picking_mode);

    ItemBase* item;

    if (picked_entity)
    {
        item = m_project_explorer.select_entity(picked_entity->get_uid());
    }
    else
    {
        m_project_explorer.clear_selection();
        item = nullptr;
    }

    m_widget->setFocus();

    return item;
}